Jump to content

*Solved* inserting error


kalivos

Recommended Posts

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:
fname
lname
email
character
sex
bday

Anyone see anything?
Link to comment
https://forums.phpfreaks.com/topic/24511-solved-inserting-error/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.