Reputation: 35235
You've got a simple table, a simple INSERT query and a quite weird result. Instead of a single empty query, the second mysql_query
call creates 2 empty records. Why?
mysql_query("
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
mysql_query("INSERT INTO `users` SET `users`.`id` = NULL");
Note: Running the query in phpMyAdmin gives the expected result - creates a single record.
Edit:
Adding the following mysql_query
call to the beginning of the snippet fixes it.
mysql_query("DROP TABLE `users`");
Edit:
Turned out the problem is related to mod_rewrite (related question).
Upvotes: 0
Views: 323
Reputation: 121922
As I understand you run this script twice.
The first time script does:
The secont time:
Try to add this line to check errors - 'echo mysql_error()."\n";'. For example -
mysql_query("
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
echo mysql_error()."\n";
Upvotes: 3