NathanLedet Posted July 15, 2008 Share Posted July 15, 2008 I'm trying to input some data, but it's throwing an error that i'm un sure about. This field in the database will store a list of file names, like so: song 1_01.mp3,song 1.mp3 but my query is wrong, some how 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 'key) VALUES ('song 1_01.mp3,song 1.mp3,', 'crp8lg3jw5tyku' at line 1 So could it be the spaces? or the commas between each song title? Quote Link to comment Share on other sites More sharing options...
NathanLedet Posted July 15, 2008 Author Share Posted July 15, 2008 Forgot to mention my PHP code for the Query: $query = "INSERT INTO downloads (files, key) VALUES ('$files', '$key')"; mysql_query($query) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
fenway Posted July 15, 2008 Share Posted July 15, 2008 No, it's the unmatched quotes -- and it's a bad idea to store lists in a single field. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 I would have to guess it has something to do with the data type of your columns. Perhaps you have it set to be an integer and you're trying to insert characters? Unless of course it's something small like maybe your table has a capital D for Downloads or maybe files should be Files. I'd say check the spelling and capitalization of all table parts and then check the data types for both columns Quote Link to comment Share on other sites More sharing options...
NathanLedet Posted July 15, 2008 Author Share Posted July 15, 2008 No, it's the unmatched quotes -- and it's a bad idea to store lists in a single field. Can you make another suggestion? The application this goes into is so that people can select x amount of files and send links to those files in an e-mail. When the user goes to a link with the random code that you saw up above (crp8lg3jw5tyku), it pulls the selected songs out of the database. I would have to guess it has something to do with the data type of your columns. Perhaps you have it set to be an integer and you're trying to insert characters? Unless of course it's something small like maybe your table has a capital D for Downloads or maybe files should be Files. I'd say check the spelling and capitalization of all table parts and then check the data types for both columns ha. Checked, double checked, triple checked spelling and capitalization. Everything is correct. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 ok but did you check the data types? I suggest taking a snapshot of the structure of your table from phpymyadmin and posting it. Quote Link to comment Share on other sites More sharing options...
NathanLedet Posted July 15, 2008 Author Share Posted July 15, 2008 Sure thing [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 not that it will work, but try making your collation uniform. So change the one in files to "latin1_swedish_ci" and try it out again Quote Link to comment Share on other sites More sharing options...
revraz Posted July 15, 2008 Share Posted July 15, 2008 KEY is a MYSQL Reserved Word, you can't use it as a fieldname unless you backtick it. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 KEY is a MYSQL Reserved Word, you can't use it as a fieldname unless you backtick it. duuuuuude that's it. editL that's a perfect example of why, when I create a table, I name my rows according to the table's name. i.e. if my table name is downloads, I start ALL my column names with "dl_" or "d_" or something simialr. That way I never run a risk of naming a column after a keyword. Plus it's easier for me to identify which variables go to which values. I suggest you do the same. Quote Link to comment Share on other sites More sharing options...
NathanLedet Posted July 15, 2008 Author Share Posted July 15, 2008 DING! THANK YOU!!!!! Quote Link to comment Share on other sites More sharing options...
NathanLedet Posted July 15, 2008 Author Share Posted July 15, 2008 KEY is a MYSQL Reserved Word, you can't use it as a fieldname unless you backtick it. duuuuuude that's it. editL that's a perfect example of why, when I create a table, I name my rows according to the table's name. i.e. if my table name is downloads, I start ALL my column names with "dl_" or "d_" or something simialr. That way I never run a risk of naming a column after a keyword. Plus it's easier for me to identify which variables go to which values. I suggest you do the same. I may just have to start taking up that practice. I appreciate your assistance Quote Link to comment Share on other sites More sharing options...
revraz Posted July 15, 2008 Share Posted July 15, 2008 I pretty much do the same. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.