JayIsAStar Posted August 6, 2013 Share Posted August 6, 2013 I am trying to insert some information into a MySQL database I hope someone can help tell me what I did wrong My Code: http://pastie.org/8213129 - Before you ask $userid; is already defined on another page before this is included and i know that is not the issue. Error: Unknown column 'cgvdfbfx' in 'field list' cgvdfbfx is the value of $posted222; Thanks in advance, Quote Link to comment Share on other sites More sharing options...
boompa Posted August 6, 2013 Share Posted August 6, 2013 Don't you want quotes around the message you're inserting? Quote Link to comment Share on other sites More sharing options...
JayIsAStar Posted August 6, 2013 Author Share Posted August 6, 2013 Errr - I'm not sure. All I know for sure is that when I output the data FROM the database there will not need to be quotes around it. I'm sorry - I'm new to this. Quote Link to comment Share on other sites More sharing options...
boompa Posted August 6, 2013 Share Posted August 6, 2013 Maybe you should give it a shot. Quote Link to comment Share on other sites More sharing options...
JayIsAStar Posted August 6, 2013 Author Share Posted August 6, 2013 I'm very sorry but i'm just not sure what you mean - I'm sure its a simple fix i'm really hoping for a fixed code snippet. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 7, 2013 Share Posted August 7, 2013 string data values must be enclosed by single-quotes inside the query statement so that they are treated as literal string data values, otherwise they are treated as identifiers (database, table, or column names - which is what is occurring in your case) or treated as mysql keywords, functions, or operators. programming requires that you know the meaning of everything in the code in front of you. to successfully write a sql query statement, you must know the syntax for the type of query you are writing, what the keywords, functions, and operators mean and where they go in the query, where the identifiers (database, table, or column names) go, where the data values go, and how to treat each different type of data. Quote Link to comment Share on other sites More sharing options...
Solution JayIsAStar Posted August 7, 2013 Author Solution Share Posted August 7, 2013 Wow I feel so dense. @boompa - I didn't even realize what you were talking about sorry about that. @mac_gyver - Thanks for the longer explanation. Results: It is indeed now working since I added the single quotes. 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.