kalivos Posted October 20, 2006 Share Posted October 20, 2006 I'm having a problem inserting some data into a database. I'm getting tired and could use an extra set of eyes.PHP[code]require_once("connect.php"); //db connection script$data = "INSERT INTO personal_data (fname, lname, email, character, sex, bday) VALUES ('$fname', '$lname', '$email', '$cname', '$sex', '$bdate')"; echo $data; mysql_query($data) or die(mysql_error());[/code]Returned[code]INSERT INTO personal_data (fname, lname, email, character, sex, bday) VALUES ('Tim', 'Withers', '********@gmail.com', 'numair', 'male', '199433')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 'character, sex, bday) VALUES ('Tim', 'Withers', '********@gma[/code]Database table personal_data:fnamelnameemailcharactersexbdayAnyone see anything? Quote Link to comment Share on other sites More sharing options...
btherl Posted October 20, 2006 Share Posted October 20, 2006 Is character a reserved word? I forget how to quote reserved words in mysql, but that's my best guess. The syntax looks fine. Quote Link to comment Share on other sites More sharing options...
Skatecrazy1 Posted October 20, 2006 Share Posted October 20, 2006 as far as I can see, there are no errors in your syntax... that truly is a weird error... all I would say is check your connect.php file, use `'s around your field names (for example INSERT INTO personal_data (`fname`, `lname`, `email`, `character`, `sex`, `bday`)), and to also make sure you reference your connection in the mysql query (if your connection is in a variable, reference it as mysql_query($sql, $connection))and if it's not in a variable, also make sure to close your connection at the end. Quote Link to comment Share on other sites More sharing options...
kalivos Posted October 21, 2006 Author Share Posted October 21, 2006 I changed the cell "character" into char_name. **POOF** it works. Guess I was a little more tired that what I originally thought :) Thanks for the help. 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.