0

別のステートメントが電子メールがデータベースに既に存在するかどうかをチェックする前に、挿入ステートメントを使用してサイトにユーザーを登録する関数を設定しました。

問題は、ユーザーデータをDBに入れようとする挿入ステートメントにあります...ブラウザはキャッチ可能な致命的なエラーを出力します:クラスmysqliのオブジェクトを文字列に変換できませんでした...

何が問題なのか本当にわかりません.Result1はエラーが表示されるクエリです。構文の観点からは、私は何か間違ったことはしていません。私は多くのシンを試しましたが、問題を見つけることができません。通常、このようなエラーは SELECT ステートメントで発生します。コードは次のとおりです。

function register_enduser($post,$connection)

{ global $errorclass;

 $name = $connection->real_escape_string($post['name']);
 $lastname = $connection->real_escape_string($post['lastname']);
 $email = $connection->real_escape_string($post['e-mail']);
 $pass_hashed = password::hash($_POST['password']); 
 $passwd =  $pass_hashed;
 $usertype= $_POST['usertype'];

 $connection->set_charset("utf8");

 $result = $connection->query("select * from users where email='".$email."'");
 if (!$result) {
     throw new Exception('error');
     return false;
 }
 elseif ($result->num_rows > 0) {
     $errorclass['existentemail'] = ' e-mail allready exists.';
     return $errorclass['existentemail'];
 } else {
     $result1 = $connection->query("insert into users values

 (NULL,'".$name."','".$lastname."','"
 .$email."','".$passwd."','".$pass_hashed."','".$usertype."')")or die($connection);
 }
 if (!$result1) {
     throw new Exception('error.');
     return false;
 } 

 return true;
 }
4

2 に答える 2