SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

NewSQLDev
Starting Member

2 Posts

Posted - 04/10/2013 :  21:28:08  Show Profile  Reply with Quote
Hi all ,

im new on SQL and i have no idea why it doesnt work



QUERY
quote:
<!DOCTYPE html>
<html>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
User<input type="text" name="user">
<input type="submit">
</form>
<?php

$user=$_POST['user'];
if(isset($user)){
$con=mssql_connect("SERVER","USER","PASSWORD");
$ID=mssql_query("select UserUID from PS_UserData.dbo.Users where UserID='$user' ");
$item=mssql_query("select ItemID from PS_GameData.dbo.UserItem where UserUID=$ID order by MakeTime");
$row=mssql_fetch_assoc($ID);
echo $row["UserUID"]."<br>";}
?>
</body>
</html>


ERROR
quote:
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near 'id'. (severity 15) in C:\xampp\htdocs\index.php on line 14

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\index.php on line 14
2


Normaly $ID should give as result "2" (without "" , its INT data )
but i got a error "Incorrect syntax near 'id'. (severity 15"

russell
Pyro-ma-ni-yak

USA
5071 Posts

Posted - 04/11/2013 :  06:17:34  Show Profile  Visit russell's Homepage  Reply with Quote
echo the actual value of it. also, shouldn't it be more like this?
"select ItemID from PS_GameData.dbo.UserItem where UserUID=" . $ID . " order by MakeTime"
Go to Top of Page

NewSQLDev
Starting Member

2 Posts

Posted - 04/11/2013 :  16:22:15  Show Profile  Reply with Quote
unfortunaly it doesnt work , please keep the comments comming :)
Go to Top of Page

russell
Pyro-ma-ni-yak

USA
5071 Posts

Posted - 04/11/2013 :  21:57:02  Show Profile  Visit russell's Homepage  Reply with Quote
Did you echo the value of the variable? And of the SQL string? That is how to troubleshoot it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000