预计参数1为资源,给定布尔值

时间:2011-11-02 03:49:26

标签: php

  

可能重复:
  PHP: Warning: sort() expects parameter 1 to be array, resource given

警告:mysql_error()要求参数1为资源,布尔值在第26行的/var/www/html/stockm/include/include.php中给出

交易失败:

select p.ProductID as product_id, p.ProductName as product_name,c.categoryname as product_catgegory, p.ProductDescription as product_desc,p.saleprice as product_price,p.Discontinued as product_dis from sm_products p inner join sm_category c on p.CategoryID=c.categoryid inner join sm_stockin si on si.productid=p.ProductID where (p.datedel='' or p.datedel is null) and p.active=1

错误Detials

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/html/stockm/include/include.php on line 100

代码:

$stmt = mysql_query($SQLStr); 
if(!$stmt) 
{ 
     echo "Transaction Fail : <br/>" . mysql_error($stmt) . "<br/>" . $SQLStr ; 
}
$row = mysql_fetch_array($stmt,MYSQL_BOTH); 

1 个答案:

答案 0 :(得分:0)

mysql_error应该给出MySQL连接,如果没有指定,则假定mysql_connect()打开的最后一个链接。只需你可以不带参数调用它。如果发生错误,您应该退出脚本。

$stmt = mysql_query($SQLStr); 
if(!$stmt) 
{ 
     die "Transaction Fail : <br/>" . mysql_error() . "<br/>" . $SQLStr ; 
}
$row = mysql_fetch_array($stmt,MYSQL_BOTH);