gpt4 book ai didi

php - mysql_fetch_array() 需要参数 1 ?怎么修?

转载 作者:太空宇宙 更新时间:2023-11-03 12:20:04 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc... expects parameter 1 to be resource

(31 个回答)


8年前关闭。




你好我收到这个错误

警告:mysql_fetch_array() 期望参数 1 是资源, bool 值在 C:\wamp\www\Dynamic [PHP WEBSITE]\includes\main_content.php 第 15 行 中给出

任何人修复此代码..

这是我的代码

<?php 
include("includes/connect.php");

$select_posts = "select * from prodcut order by rand() LIMIT 0,4";

$run_posts = mysql_query($select_posts);

while($row=mysql_fetch_array($run_posts)){ /* This is LINE no. 15*/
$post_id = $row['pid'];
$post_name = $row['name'];
$post_image = $row['image'];
$post_details = substr($row['details'],0,200);
?>

这是代码的屏幕截图..

http://i.imgur.com/Ca1cCWS.png

数据库表截图 http://img546.imageshack.us/img546/699/8ler.png

请记住:我只想在我的网站上显示每个帖子的 ID、姓名、图像和详细信息。

最佳答案

尝试错误检查:

$run_posts = mysql_query($select_posts) or die(mysql_error());

应该有一个错误,这就是它失败的原因。阅读错误 mysql_error() 打印出来并解决问题。

编辑:并阅读 MLeFevre 在您的帖子下的评论。这可能是错误。

关于php - mysql_fetch_array() 需要参数 1 ?怎么修?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20522360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com