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
 General SQL Server Forums
 Script Library
 syntax query error

Author  Topic 

raje
Starting Member

4 Posts

Posted - 2010-03-22 : 03:45:46
im not sure if this is right place, but hope someone can help me. i keep getting this syntax query error :
QUERY ERROR: 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 'WHERE userid=1' at line 1
Query was UPDATE userstats SET agility = WHERE userid=1
from following piece of code :
$expired = $db->query("SELECT userid,expire FROM users WHERE expire=0");

while($ex=$db->fetch_row($expired))
{
$findout = $db->query("SELECT strength FROM oldstats WHERE userid=".$ex['userid']."");
$findout = $db->query("SELECT agility FROM oldstats WHERE userid=".$ex['userid']."");
$findout = $db->query("SELECT guard FROM oldstats WHERE userid=".$ex['userid']."");
$update = $db->fetch_row($findout);

$db->query("UPDATE userstats SET agility = ".$update['agility']." WHERE userid=".$ex['userid']."");
$db->query("UPDATE userstats SET strength = ".$update['strength']." WHERE userid=".$ex['userid']."");
$db->query("UPDATE userstats SET guard = ".$update['guard']." WHERE userid=".$ex['userid']."");

$db->query("DELETE FROM oldstats WHERE userid=".$ex['userid']."");
}

Can someone please help me understand what ive done wrong? any help would be greatly appreciated

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-22 : 04:12:00
This is a forum for MS SQL Server and although we might be able to help you with a few things, you'll much more likely to get accurate answers to your questions in a MySQL forum.

That being said, the error message you posted shows that the value of $update['agility'] is empty, this is why the update-query you are trying to build is not parsing correctly:

$db->query("UPDATE userstats SET agility = ".$update['agility']." WHERE userid=".$ex['userid']."");

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

raje
Starting Member

4 Posts

Posted - 2010-03-22 : 05:08:17
thanx Lumbago, i been up nearly 30 hours, didnt realise i was in wrong forum.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-22 : 05:17:08
30 hours is a long time to stay focused! Good luck with whatever your doing...I hope it's worth the extra hours

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page
   

- Advertisement -