doudie2693 2012-05-22 14:46
浏览 61
已采纳

警告:mysql_fetch_array()期望参数1是资源,布尔给定[重复]

Possible Duplicate:
PHP: Warning: sort() expects parameter 1 to be array, resource given

I have the following PHP code but get this error. I tried different solutions but it does not seem to work. Any help would be greatly appreciated.

<?php
INCLUDE 'functions.php' ;

$host = 'localhost';    
$id = '***';    
$pwd = '***';    
$db = '****'; 

$myconnection = connect_db($host, $id, $pwd, $db);

$SortOn = $_POST["SortOn"];    
$SortIn = $_POST["SortIn"];


$sql = "SELECT ID, DateTime, FirstName, LastName, AdditionalInformation, Category1,    Category2, Category3, Category4, Category5, Pending, Approved, Disapproved, WebsiteName, WebsiteURL FROM 'websites' ORDER BY $SortOn $SortIn";
echo "<table border=\"1\"><tr><th>ID</th><th>Date & Time</th><th>First Name</th><th>Last Name</th><th>Additional Information</th><th>Category 1</th><th>Category 2</th><th>Category 3</th><th>Category 4</th><th>Category 5</th><th>Pending</th><th>Approved</th><th>Disapproved</th><th>Website Name</th><th>Website URL</th></tr>";

$result = mysql_query($sql);            



while ( $row = mysql_fetch_array($result))            
{                
    echo "<tr>";        
    for ( $column = 0;$column < count($row);$column++)        
    {            
        echo "<td>" . $row[$column] . "</td>";        
    }        
    echo "</tr>";    


}            
echo "</table>";

?>   
  • 写回答

3条回答 默认 最新

  • doumi1311 2012-05-22 14:55
    关注

    mysql_query returns a boolean false when an error occurs. So it looks like you have to fix your query. You can use mysql_error to figure out what the error is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂