我如何解决PDO中的此错误?
当我想使用该类旁边的其他类时,会发生此错误。
代码是bug还是应该添加代码?请引导我!
我的配置文件:(数据库为mysqli)
$db_name = "a";
$db_host = "localhost";
$db_pass = "c";
$db_user = "b";
try {
$DBH = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8", $db_user, $db_pass);
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch(PDOException $e) {
echo "connection failed !";
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}
代码:
class verify
{
public $licence;
public $factor;
public $code;
public $key;
public $secure;
public $token;
public $name;
public $email;
public $ctime;
public $cdate;
public $cr_code;
public $status;
function __construct($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l)
{
$this->licence = $a;
$this->factor = $b;
$this->code = $c;
$this->key = $d;
$this->secure = $e;
$this->token = $f;
$this->name = $g;
$this->email = $h;
$this->ctime = $i;
$this->cdate = $j;
$this->cr_code = $k;
$this->status = $l;
}
}
$cathy = new verify($Licence_code , $Factor_code , $Verify_code , $Key_saz , $Secure , $Token , $Factor_name , $Factor_email , $Now_time , $Now_date , $Date_code , 1);
$STH = $DBH->prepare("INSERT INTO `i_verfy`(`licence`, `factor`, `code`, `key`, `secure`, `token`, `name`, `email`, `ctime`, `cdate`, `cr_code`, `status`) VALUES (:licence, :factor, :code, :key, :secure, :token, :name, :email, :ctiem, :cdate, :cr_code, :status)");
$STH->execute((array)$cathy);
谢谢。
答案 0 :(得分:1)
您的查询中有错字。
$STH = $DBH->prepare("INSERT INTO `i_verfy`(`licence`, `factor`, `code`, `key`, `secure`, `token`, `name`, `email`, `ctime`, `cdate`, `cr_code`, `status`) VALUES (:licence, :factor, :code, :key, :secure, :token, :name, :email, :ctime, :cdate, :cr_code, :status)");