I have created a database on Hostmonster using the MySQL wizard and PHPadmin. The database is fine. I can add to it using PHPadmin. But this code does not add to the database when processing my form. The rest of the script works, sends out email, moves to a new page but this.... I even had PHPadmin create code, used it and it would not add. Yet I am not getting anymore errors. I would appreciate your help.
/* put it in the database
$username="steve";
$password="password";
$database="contacts";
mysql_connect("localhost", $username, $password ) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
mysql_query("INSERT INTO 'data' VALUES('$first','$last','$email','$likeit')");
mysql_close();
/*mail($sendtome,$mesubject,$datamessage);*/
Can't insert into a MySQL database
Moderator: General Moderators
-
eaglewingmd
- Forum Newbie
- Posts: 1
- Joined: Sat Apr 10, 2010 5:02 pm
Re: Can't insert into a MySQL database
In MySQL, apostrophes and quotation marks are only for strings. If you want quotes around names, like tables or fields, you need backticks.
It's the button by the 1 key.
It's the button by the 1 key.