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? Quote 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? Quote 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'"; Quote 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 Quote 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 . "'"; Quote 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? Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/124980-help-with-php-query/#findComment-653275 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.