PLEASE HELP, sql query not working

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

PLEASE HELP, sql query not working

Post 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')";
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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 )
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

Post 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.
Post Reply