I want to add a line into mysql via php.
In short, the code looks like:
$email = mysqli_real_escape_string($mysqli, $_POST['email']);
$token = md5(uniqid(rand(), true));
$mysqli->query('SET NAMES utf8');
$insertsignup = "INSERT INTO `betasignup`(`signupDate`, `email`, `token`, `activated`) SELECT CURDATE(), '" . $email . "', '" . $token . "', 'N';";
echo $insertsignup;
$insert = $mysqli->query($insertsignup) or
die(mysqli_error($mysqli));
the "echo" was inserted to debug the query.
Output:
INSERT INTO
betasignup
(signupDate
,token
,activated
) SELECT CURDATE(), '[email protected]', '58d15fe49629b3942a58acfb64a0cb07', 'N';
followed by:
Unknown column 'token' in 'field list'
Here is the table:
CREATE TABLE IF NOT EXISTS `betasignup` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`signupDate` date NOT NULL,
`email` text NOT NULL,
`token` text NOT NULL,
`activated` enum('Y','N') NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
The Query works perfectly when inserted into phpmyadmin or mysql-commandline.
On localhost dev-environment it works, in live (web) not.
Any ideas?
Your production database is probably not similar as the one in your dev environment? It is apparently missing the 'token' field live.