我似乎无法找到此错误的原因:PDOStatement :: errorCode():42S22Array([0] => 00000 [1] => [2] =>)

时间:2016-05-04 01:18:44

标签: php html mysql

我搜索了一个我收到“未找到列”错误的原因,但是我疲惫的眼睛找不到它。我还想知道Array([0] => 00000 1 => [2] =>)是什么意思。

PHP

<?php
require_once('dbconnect.php');
function AddNewAccount() {
    //var_dump($_POST); exit;
    try {
        $acctType = $_POST["user-type"];
        if (!isset($acctType) || empty(trim($acctType))) {
            throw new Exception('You must select an account type.');       
        };
        $name = $_POST["name"];
        if (!isset($name) || empty(trim($name))) {
            throw new Exception('You must enter your name.');       
        };
        $company = $_POST["company"];
        if (!isset($company) || empty(trim($company))) {
            throw new Exception('You must enter your company name.');       
        };
        $street = $_POST["address"];
        if (!isset($street) || empty(trim($street))) {
            throw new Exception('You must enter your street address.');       
        };
        $city= $_POST["city"];
        if (!isset($city) || empty(trim($city))) {
            throw new Exception('You must enter your city.');       
        };
        $state = $_POST["state"];
        if (!isset($state) || empty(trim($state))) {
            throw new Exception('You must enter your state.');       
        };
        $zipcode = $_POST["zip"];
        if (!isset($zipcode) || empty(trim($zipcode))) {
            throw new Exception('You must enter your zipcode.');       
        };
        $email = $_POST["email"];
        if (!isset($email) || empty(trim($email))) {
            throw new Exception('You must enter your email.');       
        };
        $password = $_POST["pwd"];
        if (!isset($password) || empty(trim($password))) {
            throw new Exception('You must enter your password.');       
        } else
        $password=crypt($passwword);

        $dbh = connect2DB();
        $stmt = $dbh->prepare('INSERT INTO Accounts(UserType, `name`, Company, StreetAddress, City, State, Zipcode, Email, Password) 
                               VALUES($acctType, $Name, $company, $street, $city, $state, $zipcode, $email, $password)');
        if (!$stmt->execute()) {
            echo "\nPDOStatement::errorCode(): ";
            print $stmt->errorCode();
            print_r($dbh->errorInfo());
        } else 
            echo "Account added.";
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }    
}
AddNewAccount();
?>

表格定义

enter image description here

Web-Page

0 个答案:

没有答案