PHP Prepare method not working when calling it twice?

前端 未结 2 547
一生所求
一生所求 2021-01-14 06:58

I am using the prepare method as follows:

$db= new mysqli("localhost","***","***","***");

if ($db->connect_error)          


        
2条回答
  •  日久生厌
    2021-01-14 07:28

    You need read $stmt->error;

    To read, you need rewrite code as in the example below.

    ...
    $stmt = new mysqli_stmt($db);
    if($stmt->prepare('SELECT name FROM table WHERE id = ? '))
    {
      $stmt->bind_param('i', $id);
      $stmt->execute();
      echo "Success
    "; } else { var_dump($stmt->error); } ...

提交回复
热议问题