Jump to content

[SOLVED] Syntax Error


NathanLedet

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.