PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
$sessid = session_id();
if(!($result = @mysql_query("SELECT * FROM user_active WHERE sessid=\"".$sessid."\" AND userid=".$_SESSION['userid']." AND ip=\"".$_SERVER['REMOTE_ADDR']."\"", $connection)))
ShowError();
?>
The query gives me this error:
Error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
I guess I'm just missing something.
Any help would be greatly appreciated!
Thanks in advance.
if(!($result = @mysql_query("SELECT * FROM user_active WHERE sessid='".$sessid."' AND userid=".$_SESSION['userid']." AND ip='".$_SERVER['REMOTE_ADDR']."'", $connection)))
The $_SESSION['userid'] is set, 10 in this case. And, when I just echo out the $query, everything seems to be fine:
SELECT * FROM user_active WHERE sessid="68bf87dc2e45282b98fdcae0e5cd39xx" AND userid=10 AND ip="xx.xxx.xx.xxx"
Putting quotes around the userid doesn't seem to make a difference...
Error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Strange thing is that the "Could not get the selected data: " part isn't displayed... Though I'm very sure this query produces the error!
[Shame Mode]
The error was produced by a function that is called right after that query I posted here... I gave it $_SESSION['userId'] as parameter, but it had to be $_SESSION['userid']... That produced the error.
[/Shame Mode]
Omg I'm really taking down the status I didn't have.
Sorry to waste your time with my looking-not-carefully-enough
Thanks for your time, and I'll eventually learn from these stupid mistakes
No prob. I'm sure most of us have done something along those lines. One this I would suggest is to set up error checking on all your db interaction, if for nothing else, then for telling you where and why things get porked. Just a suggestion, and good luck with the rest of your script.