-2

可能重复:
mysql_fetch_array() 期望参数 1 是资源,选择中给出的布尔值

例如,如何让 php 获取字母和数字
http://www.mywebsite.com/chatBody.php?chat_code=9BYELZ0WxdQr4An

我是我正在使用的所有代码:

$sql = "SELECT * FROM chat WHERE chat_members_code = " . mysql_real_escape_string($_GET['chat_code']);
$chat = mysql_query($sql);

while($row = mysql_fetch_array($chat)) {

$chat_id = $row['id'];
$user_1_id = $row['user_1_id'];
$user_1_fullname = $row['user_1_fullname'];
$user_1_username = $row['user_1_username'];
$user_2_id = $row['user_2_id'];
$user_2_fullname = $row['user_2_fullname'];
$user_2_username = $row['user_2_username'];
$chat_body = $row['chat_body'];
$chat_members_code = $row['chat_members_code'];
$chat_time = $row['chat_time'];
$chat_date = $row['chat_date'];
$chat_datetime = $row['chat_datetime'];

}

它显示了这个错误:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\LiveChat\php\chatBody.php on line 21
4

1 回答 1

0

试试这个

   $chatCode = mysql_real_escape_string($_GET['chat_code']) ;
   $sql = "SELECT * FROM chat WHERE chat_members_code =  '".$chatCode."' ";
于 2013-02-02T22:21:56.417 回答