3

what is wrong with this sql query? he is crying on NOW() :(

("INSERT INTO " . PREFIX . "messages (from, to, title, message, date) 
VALUES (" . $from . ", " . $to . ", " . $subject . ", " . $message . ", NOW())");
6
  • 3
    What error message are you getting? Commented Feb 25, 2010 at 15:45
  • Also, consider wrapping your variables into '. Commented Feb 25, 2010 at 15:49
  • 2
    You have a SQL injection vulnerability. Commented Feb 25, 2010 at 15:49
  • 1
    I hope you have escaped those variables using mysql_real_escape_string or something like that before passing it to the query. Commented Feb 25, 2010 at 15:55
  • 2
    Please provide the error message. Error messages are there for a reason. ;) Commented Feb 25, 2010 at 16:04

2 Answers 2

3

Are you using MySQL or Microsoft SQL Server? NOW() doesn't work in SQL Server; need to use GETDATE() instead.

Sign up to request clarification or add additional context in comments.

4 Comments

GETDATE() is SQL Server specific - this question is for MySQL. CURRENT_TIMESTAMP is ANSI standard however, supported on both.
Woops, I've been trapped in the SQL Server world for too long.
FYI: the original question did not specify SQL or MySQL
-2

Maybe using current time stamp would be better idea, I don't know it, just type timestamp in mysql you'll find it on google

Comments

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.