I will do a sanitize and escape as soon as I get this to work properly.
Database connection and selection are verified working with a select query at this point. Weird thing is, if I take this insert query and run it straight from a mysql command prompt, it inserts just fine.
subscibers table has 3 columns not allowing NULL in either column:
Server version: 5.5.11 MySQL Community Server (GPL)
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| email | varchar(45) | NO | UNI | NULL | |
| active | tinyint(4) | YES | | 1 | |
+--------+-------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)
Code in php:
$query = "INSERT INTO `subscribers`(`id`,`email`) VALUES(default,'ggg@nothing.com')";
print $query;
mysql_query($query) or die(mysql_error());
printed query result for insert:
INSERT INTO `subscribers`(`id`,`email`) VALUES(default,'ggg@nothing.com')
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 ”ggg@nothing.com’)’ at line 1
EDIT: I am sure that there is no other email in there identical for uniqueness. Looking at the table list of emails, and none with that garbage in there.
don’t include id in your insert statement:
OR set
idtoNULL