0

This is the error i'm receiving 1064 - 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 ':i:s a), rec_type = '', rec_request = '1', rec_by = 'Victoria', batch_id = UC' at line 1

also i'm aware that I need to escape before inserting. I'm just testing right now.

$importwav="INSERT into names SET 
com_id = '".$word_id."',
rec_date = date(d-M-y),
rec_time = date(h:i:s a),
rec_type = '".$rec_type."',
rec_request = '1',
rec_by = '".$data[8]."',
batch_id = UCASE('".$batchid."')
";


    INSERT into names SET com_id = '87', rec_date = date(d-M-y), 
rec_time = date(h:i:s a), rec_type = '', rec_request = '1', 
rec_by = 'Victoria', batch_id = UCASE('Batch004AM')
3
  • rec date could be of Y-m-d format Commented Dec 12, 2010 at 14:39
  • make single rec_date field of datetime type and assign both date and time at once with rec_date=localtime. Commented Dec 12, 2010 at 14:42
  • 1
    don't be a fool, use proper date format Commented Dec 12, 2010 at 14:50

3 Answers 3

3

You're confusing your PHP functions and your MySQL functions.

$importwav="INSERT into names SET 
com_id = '".$word_id."',
rec_date = '" . date('d-M-y') . "',
rec_time = '" . date('h:i:s a') . "',
 ...

And your SQL syntax is FUBAR.

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

2 Comments

Hmmm... Inacio says your SQL syntax is FUBAR and gets 3 votes. I say your SQL syntax is improper and get a negative vote. Oh well..
@Brian he is wrong with that remark and the rest of the answer is okay (save for not to mention lame data format). While your answer actually helps nothing and, as the op mentioned in the comment, being used literally, can't solve the problem. Because his ptoblem is different. Just write your answers on topic to get upvotes. That's damn easy.
0

Improper SQL syntax.

INSERT INTO table (col1, col2) VALUES (val1, val2)

1 Comment

i use to do it that way, but it gets way to confusing when inserting a lot of field entries.
-1

date() arguments need to be a string. Try surrounding your date format strings with single quotes (').

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.