php - bind_param what causing the error -
$conn = new mysqli(db_host, db_user, db_password, db_name); if($conn->connect_error) { $this->last_error = 'cannot connect database. ' . $conn->connect_error; } mysqli_set_charset($conn, 'utf8'); // 2. select database use $db_select = mysqli_select_db($conn, db_name); if (!$db_select){ die("database selection failed: " . mysqli_error()); }; $query = $conn->prepare( "insert user (id, name, gender, email, age, text, score) values (null, ?, ?, ?, ?, ?, ?)" ); $query->bind_param('sssssi', $name,$gender,$email,$age,$text,$score); $query->execute(); $query->close();
i having error:
call member function bind_param() on non-object
but when switch other computer , use it, no error.
you should make catching error messages:
if(!($query = $conn->prepare("insert user (id, name, gender, email, age, text, score) values (null, ?, ?, ?, ?, ?, ?)"))) die($conn->error); if(!$query->bind_param('sssssi', $name,$gender,$email,$age,$text,$score)) die($conn->error); $query->execute(); $query->close();
please see output if there further assistance.
Comments
Post a Comment