2017-04-16 10 views
1

何が問題になりますか?致命的なエラー:42行目のC: xampp htdocs website adduser.phpのブール値でメンバー関数execute()を呼び出す

function db(){ 
     $con= new mysqli('localhost' , 'root','','signupsystem') or die("fail". mysqli_connect_error()); 

     $queryb="Insert into adduser(name,fathername,gender,address,cnic,contactnumber,email,password) values($this->name,$this->fathername, 
       $this->gender,$this->address,$this->cinic_no,$this->contact_n0, $this->email , $this->password)"; 

     $result = $con->query($queryb); 
    if (!$result) { 
     die($con->error); 
    } 
     $stmt = $con->prepare($queryb); 

       if($stmt === "false") 
       { 
        trigger_error('Wrong Sql:' . $queryb . ' Error ' . $this->con->error, E_USER_ERROR); 
       } 
           $stmt->execute(); 
       $af = $stmt->affected_rows; 
     $con->close(); 
     return $af; 

    } 
+0

は 'false'との比較'' false ''ではありません。 –

+0

変更後falseエラーが発生しました "SQL構文に誤りがあります。正しい構文をMariaDBサーバーのバージョンに対応するマニュアルで確認してください。 '6110197860375,03414216670、[email protected]'の近くで使用してください) ' 2 " – Mudassar

+0

正確には、あなたのsqlを見て、そのエラーを修正してください。 –

答えて

2

これらの2つのことが適切ください:

$queryb="Insert into adduser(name,fathername,gender,address,cnic,contactnumber,email,password) values($this->name,$this->fathername, 
      $this->gender,$this->address,$this->cinic_no,$this->contact_n0, $this->email , $this->password)"; 
常に "'.$this->cinic_no.'"

と比較するように単一引用符と連結すること

文字列フィールド、それが好き:

if($stmt === false) // not "false" 
+0

ありがとうございました。あなたの答えは本当に助かります。 – Mudassar

+0

@Mudassarは誰もここにいません。それがあなたを助けるほど素晴らしいと思う。 –

関連する問題