我實際上嘗試mysqli->fetch_array();
獲取數組,但不能工作,所以我用bind_result();並且它拋出下面的錯誤bind_result失敗
Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement
所以我做了一個bind_result錯誤檢查和我得到了什麼是bind_result() failed:
等什麼我真的做錯了嗎?
$wtf = "";
$hello = "";
$check_empty_field = $mysqli - > prepare("select `username`, `firstname`, `lastname` from `vpb_uploads` where `username` = ? and `firstname` = ? and `lastname` = ?");
$check_empty_field - > bind_param('sss', $username, $wtf, $hello);
$check_empty_field - > execute();
$check_empty_field - > store_result();
if($check_empty_field - > num_rows < 1) {
$date = date("d-m-Y");
$i2 = '';
$i3 = '';
$i4 = '';
$i5 = '';
$insert = $mysqli - > prepare("insert into `vpb_uploads` (`username`, `firstname`, `lastname`, image_one, image_two, image_three, image_four, image_five, date)values(?,?,?,?,?,?,?,?,?)");
$insert - > bind_param('sssssssss', $username, $wtf, $hello, $random_name_generated, $i2, $i3, $i4, $i5, $date);
$insert - > execute();
$identity = "image_one";
} else {
$get_empty_field = $check_empty_field - > bind_result($username, $wtf, $hello);
if(false === $get_empty_field) {
die('bind_result() failed: '.htmlspecialchars($mysqli - > error));
}
$image_one = strip_tags($get_empty_field["image_one"]);
$image_two = strip_tags($get_empty_field["image_two"]);
$image_three = strip_tags($get_empty_field["image_three"]);
$image_four = strip_tags($get_empty_field["image_four"]);
$image_five = strip_tags($get_empty_field["image_five"]);
global $identity;
}
你不是包括所有相關的代碼,其中'$ stmt'初始化?還有' - >'真的可以處理這些額外的空間嗎? – 2013-04-06 22:51:28
@從此遺憾,這是錯字。 – magnsta 2013-04-06 22:59:32
另外,是否定義了$ $ username? (雖然我不認爲這是bug) – 2013-04-06 23:16:51