0

I have function that updates log table.

function wslog($userID, $log, $where) {
    safe_query("INSERT INTO ".PREFIX."log ( time, userID, log, where ) values( '".time()."', '".$userID."', '".$log."', '".$where."' ) ");
}

And I have this php code:

wslog($userID, 'server|'.mysql_insert_id().'', 'servers');

But I keep getting syntax error:

  • Query failed: errorno=1064
  • 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 ) values( '1269208030', '1', 'server|14', 'servers' )' at line 1
  • query=INSERT INTO ws_DII_log ( time, userID, log, where ) values( '1269208030', '1', 'server|14', 'servers' )

1 Answer 1

2

Is it possible that SQL doesn't like your log field name as it is a reserved word?

If so, try putting it is backticks

log ( `time`, `userID`, `log`, `where` )
Sign up to request clarification or add additional context in comments.

2 Comments

I would have said it was the where, rather than the log. But either way backticking it is a good idea
nvm, I renamed where row, I guess it affected the query somehow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.