Page 1 of 1

PLEASE HELP, sql query not working

Posted: Tue Jan 23, 2007 5:04 am
by dhrosti
If been getting so frustrated with this...

Im trying to insert data into a MySQL db but i get errors saying 'check the syntax', etc.

Code: Select all

$query = "INSERT INTO files (name, desc, type, size, path, clientid, date) VALUES ('$fileName', '$desc', '$fileType', '$fileSize', '$filePath', '$client_id', '$date')";

Posted: Tue Jan 23, 2007 7:02 am
by onion2k
Are you escaping the data? mysql_real_escape_string() will help if you're not. You should also be aware that things like 'date' are reserved words in MySQL. It'll let you use it as a column name but it's not really a good idea. ( http://dev.mysql.com/doc/refman/5.0/en/ ... words.html )

Posted: Tue Jan 23, 2007 8:28 am
by dhrosti
I changed the column names and the scripts, etc and its working now, thanks for your help, i didnt know about those reserved terms.