...

View Full Version : Trying to UPDATE a record. Getting a SQL error. Help!



sctwest
03-24-2004, 02:18 PM
I am following this from a book. Can anyone tell me if this is right, if it is then I will look somewhere else for the error?

This is the error:
You have an error in your SQL syntax near 'date_recvd = '0000-00-00', last_name = 'ssssssss', first_name = 'aaaaaaaaaa' at line 3

$sql = "UPDATE $table_name SET
job_number = '$_POST[job_number]'
date_recvd = '$_POST[date_recvd]',
last_name = '$_POST[last_name]',
first_name = '$_POST[first_name]',
organizat = '$_POST[organizat]',
assgn1 = '$_POST[assgn1]',
assgn2 = '$_POST[assgn2]',
assgn3 = '$_POST[assgn3]',
date_due = '$_POST[date_due]',
recvd_cao = '$_POST[recvd_cao]',
rb_review = '$_POST[rb_review]',
cost = '$_POST[cost]',
status = '$_POST[status]',
subject = '$_POST[subject]',
letter_sent = '$_POST[letter_sent]',
recvd_cao1 = '$_POST[recvd_cao1]',
recvd_cao2 = '$_POST[recvd_cao2]',
rb_rev1 = '$_POST[rb_rev1]',
rb_rev2 = '$_POST[rb_rev2]',
WHERE _id = '$_POST[_id]'";

firepages
03-24-2004, 04:21 PM
missing a comma after
job_number = '$_POST[job_number]' ,

mordred
03-24-2004, 04:22 PM
You forgot a comma to seperate the values job_number and date_recvd. It should be:



job_number = '$_POST[job_number]',
date_recvd = '$_POST[date_recvd]',


You ain't cleaning the incoming data? addslashes, mysql_escape_string, API functions could be helpful for you.

EDIT: This round goes to firepages, leaving mordred behind in the dust... :)

firepages
03-24-2004, 04:41 PM
hah , beat you by a whole minute ... ok I typed less :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum