-1
Possible Duplicate:
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given error錯誤:警告:mysqli_fetch_array()預計參數1被mysqli_result
我知道這已得到解決一百萬次,但我似乎無法弄清楚。我一直得到這個錯誤:警告:mysqli_fetch_array()期望參數1爲mysqli_result,布爾在第24行給出。這裏是我的代碼到目前爲止:
<?php
//Connect to the database
require('mysql_connect.php') ;
$query = "SELECT * FROM students WHERE alumni = 'Yes' AND shipped = 'Yes'" ;
$result = mysqli_query($dbc, $query) or die(mysqli_error($dbc) . '<br />' . $query) ;
$num = mysqli_num_rows($result) ;
if ($num >= 1) {
while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$full_name = $row['first_name'] . ' ' . $row['middle_name'] . ' ' . $row['last_name'] ;
$query = "INSERT INTO alumni_center (student_id, full_name, phone, address, city, state, postal_code, enrollment_url, active, enrollment_date) VALUES ({$row['student_id']}, '$full_name', '{$row['phone']}', '{$row['address']}', '{$row['city']}', '{$row['state']}', '{$row['postal_code']}', '{$row['registration_url']}', 'Yes', '{$row['alumni_registration_date']}')" ;
$result = mysqli_query($dbc, $query) or die(mysqli_error($dbc) . '<br />' . $query) ;
}
} else {
echo 'Only 1' ;
}
echo 'Done' ;
?>
我已經在phpmyadmin運行這兩個查詢,他們的查詢工作正常。而不是循環所有的學生,它只是通過1名學生,並插入到校友中心表中。它應該做的所有的學生,不只是1.任何幫助,非常感謝!
@MarkBaker是正確的。這是一個常見的缺乏注意力的錯誤。 – 2012-01-03 17:00:49