I am trying to get MySQL to work for my forms. I have a problem when I try to insert into a table.
When I put the information in my form and click submit (in this example, the information is “Idea” in one field and “Description” in another) I get this answer:
"You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to" desc ". VALUES (" Idea "," Description ")" on line 1 "
I am running a .php file from a web server to execute this script.
Here is my current code:
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("date_ideas") or die(mysql_error());
$title=$_POST['title'];
$title=mysql_real_escape_string($title);
$desc=$_POST['desc'];
$desc=mysql_real_escape_string($desc);
$submit="INSERT INTO ideas (title, desc) VALUES ('$title','$desc');";
mysql_query($submit) or die(mysql_error());
echo ("Idea submitted. Click <a href='Webroot/submit.php'>here</a> to go back and post another idea.");
?>
, , .