Page 1 of 1

Can't insert into a MySQL database

Posted: Sat Apr 10, 2010 5:09 pm
by eaglewingmd
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);*/

Re: Can't insert into a MySQL database

Posted: Sat Apr 10, 2010 7:23 pm
by requinix
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.