Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Problem

Author  Topic 

NewSQLDev
Starting Member

2 Posts

Posted - 2013-04-10 : 21:28:08
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

5072 Posts

Posted - 2013-04-11 : 06:17:34
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 - 2013-04-11 : 16:22:15
unfortunaly it doesnt work , please keep the comments comming :)
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-04-11 : 21:57:02
Did you echo the value of the variable? And of the SQL string? That is how to troubleshoot it.
Go to Top of Page
   

- Advertisement -