paschim Posted September 19, 2008 Share Posted September 19, 2008 function ltupdate($db,$user) { $now=time(); $upd_sql = "UPDATE $userRegTable SET accountLastActivity='$now' WHERE userName='$user'"; $sqlupd = $db->query($upd_sql); return true; } I am getting a error saying I have wrong syntax in the mysql query!, any ideas? Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/ Share on other sites More sharing options...
anon_login_001 Posted September 19, 2008 Share Posted September 19, 2008 Is there any way you can show the actual error, or better - the actual query being sent? Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-645761 Share on other sites More sharing options...
Maq Posted September 19, 2008 Share Posted September 19, 2008 $upd_sql = "UPDATE $userRegTable SET accountLastActivity='$now' WHERE userName='$user'"; Should be: $upd_sql = "UPDATE '$userRegTable' SET accountLastActivity='$now' WHERE userName='$user'"; Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-645763 Share on other sites More sharing options...
paschim Posted September 19, 2008 Author Share Posted September 19, 2008 I tried that but i keep getting that weird error, MySQL 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 ''' SET accountLastActivity='1221848460' WHERE userName='guest'' at line 1 Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-645770 Share on other sites More sharing options...
Maq Posted September 19, 2008 Share Posted September 19, 2008 Try this, not sure if it will help... $upd_sql = "UPDATE '" . $userRegTable . "' SET accountLastActivity = '" . $now . "' WHERE userName = . '" . $user . "'"; Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-645776 Share on other sites More sharing options...
paschim Posted September 19, 2008 Author Share Posted September 19, 2008 weirdly that worked, but can you tell me why i was getting that weird output in the previous case? Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-645783 Share on other sites More sharing options...
fenway Posted September 29, 2008 Share Posted September 29, 2008 Don't quote table identifiers. Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-653275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.