我試圖讓下面的代碼工作,但它不工作,並給了我下面的錯誤mysqli的編制報表fetch_array
Fatal error: Call to a member function bind_param() on a non-object in
有什麼辦法來獲取與預處理語句的數組?
if (move_uploaded_file($_FILES['file_to_upload']['tmp_name'], $final_uploads_location))
{
$stmt = $mysqli->prepare("select * from test where `username` = ? and `age` = ? ");
$stmt->bind_param('ss', $username, $age);
$stmt->store_result();
$stmt->execute();
if($stmt->num_rows < 1)
{
$insert = $mysqli->prepare("insert into `test`(`username`, `age`,) values(?,?)");
$insert->bind_param('ss', $username, $age);
$insert->execute();
}
else
{
$check = mysqli_fetch_array($stmt);
global $identity;
}
}
不錯,但即使我得到那個工作的mysqli_fetch_array將是一個麻煩的樣子。如何使用預處理語句獲取數組? –
@MarkLubo,在查詢後探索[mysqli :: $ error](http://www.php.net/manual/en/mysqli.error.php) – sectus