下面是代码.........我一个,得到错误 - 警告: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