クラス内の関数を介してMySqlに接続しようとしています。同じことがより簡単に実行できますが、これは学習の経験でもあります。 mysqli_error()は空白を返し、mysqli_errno()は0を返します。エラーを手動でmysqlに入力しましたが、dbのカラムが短すぎます。 mysqli_error()やmysql_errno()でエラーが報告されない理由を理解できません。助けを前にありがとう。PHPのレポートからのmysqlエラー報告0
<?php
class FrmAddProduct {
protected function getDbConnection(){
return new mysqli("localhost", "root", "****", "test");
}
/**
*all variables are declares and assigned here
*
**/
function commitSignUp(){
$commitSignUp = "INSERT INTO Login (`logTitle`,`logFirstName`, `logLastName`,`logLandLine`,) VALUE (\"$this->title\", \"$this->firstName\",\"$this->lastName\", \"$this->landLine\",)";
if ($this->getDbConnection()->query($commitSignUp)){
echo "The new product is added.";
return 1;
} else {
echo "Mysql reported this error description: ".mysqli_error($this->getDbConnection()."<br>";
echo "Mysql reported this error number: ".mysqli_errno($this->getDbConnection());
return 0;
}
あなたはMySQLiをOOPスタイルと手続きスタイルを混合している...どちらか一方を使用してこれを行うには、混在させることはできません。マニュアルの詳細:http://php.net/manual/en/mysqli.error.php –