Sili
Sili

Reputation: 175

unknown column 'X' in field list

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, email, 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?

Upvotes: 1

Views: 362

Answers (2)

Sili
Sili

Reputation: 175

Found it:

just moved the whole thing from webhoster to own rootserver and did not update my brain...

database was also moved to rootserver. phpmyadmin was still webhost...

of course column 'token' WAS missing.

thanks!

Upvotes: 0

purpleninja
purpleninja

Reputation: 374

Your production database is probably not similar as the one in your dev environment? It is apparently missing the 'token' field live.

Upvotes: 2

Related Questions