简体   繁体   中英

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(), 'username@email.com', '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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM