Jump to content

php not inserting data into mysql


Stealth549
 Share

Recommended Posts

Hello, getting back into php/mysql. Currently working on a project to store user infomation into a database to make stats later on.I get an error while trying to enter the infomation into the database and I cant see why it wont work, probably some small silly typo.you can see the error in action here

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 ''clients' (ip, countryName, countryCode, host, user_agent, date) VALUES('81.187.' at line 1
$sql = "INSERT INTO 'clients' (ip, countryName, countryCode, host, user_agent, date) VALUES('$cookie_ip', '$countryName', '$countryCode', '$host', '$user_agent', '$date')";				print_r($sql);		echo "<br />";		mysql_query($sql) or die(mysql_error());

Link to comment
Share on other sites

"clients" should be quoted with `, not with '.If you still get a syntax error, use the same kind of quotation around the column names.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...