我一直在試圖找出是什麼導致這個錯誤,但由於某種原因。它只是不會顯示!持續警告:mysql_fetch_array()預計參數1是資源
它已經給我這樣的警告消息:
警告:mysql_fetch_array()預計參數1是資源,布爾在C中給出:\ XAMPP \ htdocs中\ EIS \上線64 usercp.inc.php
我試過使用mysql_error();
但它沒有顯示任何東西。
這裏是我的代碼:
<?php
$firstname = getuserfield('txtFname');
$lastname = getuserfield('txtLname');
echo 'Hello '.$firstname.' '.$lastname.'.<br/>';
$anotif = 0;
$dnotif = 0;
$anotif = $anotif + getuserfield('approved_notif');
$dnotif = $dnotif + getuserfield('disapproved_notif');
?>
<h3>Notifications:</h3>
Approved:<?php if($anotif<1){echo 0;} else { echo '<a href="?anotif">'.$anotif.'</a>';}?><br/>
<?php
if(isset($_GET['anotif'])) {
$query = "SELECT * FROM hrf_leave WHERE empid = '$empid' AND formStatus = 1 AND checked = 0";
$query_run = mysql_query($query) or die($query."<br/><br/>".mysql_error());
echo "<table border=1>
<tr>
<th>Type of Leave</th>
<th>Specific Reason</th>
<th>Date From</th>
<th>Date To</th>
<th>Number of Days</th>
</tr>";
echo "<tr>";
while($record = mysql_fetch_array($query_run)){ // <------- this is line 64
$leave_id = $record['leave_id'];
echo "<td>" . $record['type_of_leave'] . "</td>";
echo "<td>" . $record['specific_reason'] . "</td>";
echo "<td>" . $record['date_from'] . "</td>";
echo "<td>" . $record['date_to'] . "</td>";
echo "<td>" . $record['num_of_days'] . "</td>";
echo "</tr>";
$query = "UPDATE hrf_leave SET checked=1 WHERE leave_id = $leave_id";
if($query_run = mysql_query($query)){
$anotif = $anotif-1;
$query = "UPDATE hrf_leave SET approved_notif=$anotif WHERE empid = $empid";
if($query_run = mysql_query($query)){
echo 'Recently approved requests';
}
}
}
echo "</table>";
}
?>
Disapproved:<?php if($dnotif<1){echo 0;} else { echo '<a href="?dnotif">'.$dnotif.'</a><br/>';} ?>
<?php
if(isset($_GET['dnotif'])) {
$query = "SELECT * FROM hrf_leave WHERE empid = '$empid' AND formStatus = 2 AND checked=0";
$query_run = mysql_query($query);
echo "<table border=1>
<tr>
<th>Type of Leave</th>
<th>Specific Reason</th>
<th>Date From</th>
<th>Date To</th>
<th>Number of Days</th>
</tr>";
echo "<tr>";
while($record = mysql_fetch_array($query_run)){
$leave_id = $record['leave_id'];
echo "<td>" . $record['type_of_leave'] . "</td>";
echo "<td>" . $record['specific_reason'] . "</td>";
echo "<td>" . $record['date_from'] . "</td>";
echo "<td>" . $record['date_to'] . "</td>";
echo "<td>" . $record['num_of_days'] . "</td>";
echo "</tr>";
$query = "UPDATE hrf_leave SET checked=1 WHERE leave_id = $leave_id";
if($query_run = mysql_query($query)){
$dnotif = $dnotif-1;
$query = "UPDATE hrf_leave SET disapproved_notif=$dnotif WHERE empid = $empid";
if($query_run = mysql_query($query)){
echo 'Recently disapproved requests';
}
}
}
echo "</table>";
}
?>
反正,我一直在試圖輸出的請假單衛生組織檢查字段值= 0。一旦看出,系統將其設置爲1。一旦鏈接被點擊,所有批准和未批准的通知值都將等於零。
這是我的迷你通知系統。但我不能得到它,因爲這個錯誤的工作..:/
可能重複的[mysql \ _fetch \ _array()期望參數1是資源,布爾給出在選擇](http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1資源布爾給定選擇) – igorw 2013-02-21 11:47:47
可能是沒有返回。 – 2013-02-21 11:51:21
@MartyWallace'register_globals'也許? : -/ – 2013-02-21 11:51:43