Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm a newbie and I've been trying for over an hour to solve this simple query:

mysql_query("INSERT INTO `tracks` (artistID, albumID, format, trackID, niceTitle, title, trackNumber, description, pictureURL, playCount) VALUES('$artistID', '$albumID[$i]', 'hq','$ID[0]', '$trackName', '$title', '$j', '$description', '$pictureURL', '$playCount'") or die(mysql_error());

I just get this error every time:

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 '' at line 1

I've done mysql_escape_string() on all variables too. Any ideas?

share|improve this question
6  
Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial. –  STT LCU May 2 '13 at 14:34
2  
You are missing the ) for the VALUES –  kingkero May 2 '13 at 14:34
    
Uff, 20 years later, people still using deprecated stuff :/ –  Andrius Naruševičius May 2 '13 at 14:35
add comment

2 Answers

up vote 7 down vote accepted

You are missing the final closing ):

mysql_query("INSERT INTO `tracks` (artistID, albumID, format, trackID, niceTitle, title, trackNumber, description, pictureURL, playCount) VALUES('$artistID', '$albumID[$i]', 'hq','$ID[0]', '$trackName', '$title', '$j', '$description', '$pictureURL', '$playCount')") or die(mysql_error());
share|improve this answer
add comment

You have no ending parenthesis ")" in your query

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.