下面是代碼.........我一個,得到錯誤 - 警告:mysql_fetch_assoc()預計參數1是資源
<?php
include('../inc/php/inc/dbc.php');
$query = "SELECT * FROM available_fsv WHERE a_status = '1'";
$result_query = mysql_query($query);
while($row = mysql_fetch_assoc($result_query)){
$billingid = $row['billingid'];
$query = "UPDATE available_fsv SET b_status = '1' WHERE billingid = '$billingid'";
$result_query = mysql_query($query);
echo $result_query;
}
?>
我收到錯誤..... ......
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\php\fsv_shutdown_cron.php on line 6
數據庫結構like--
____________________________________________________
| id | a_status | b_status | billingid |
|--------|------------|-------------|--------------|
| 1 | 1 | 0 | 1 |
|--------|------------|-------------|--------------|
| 2 | 0 | 0 | 12 |
|--------|------------|-------------|--------------|
| 3 | 0 | 0 | 9 |
|--------|------------|-------------|--------------|
| 4 | 1 | 0 | 3 |
|________|____________|_____________|______________|
我想做的事是,如果a_status是1,那麼更新b_status爲1
我正在學習PHP,我知道這是一個愚蠢的問題,但請幫助我。在此先感謝.. :)
你確定你已經連接到db?在做'include'後試試'echo mysql_error' – 2013-02-18 09:17:32
請在phpmyadmin上運行這個查詢並檢查結果。 – vin 2013-02-18 09:21:55
你把'$ query'和'$ result_query'搞亂了,它們在代碼中出現兩次,看到我的回答在 – 2013-02-18 09:22:41