gpt4 book ai didi

php - 警告 : mysql_fetch_object(): supplied argument is not a valid MySQL result resource

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

见鬼去吧当我尝试连接并从数据库中提取内容时,出现以下错误:

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/content/49/5548763/html/matt/download.php on line 17

该站点上的其他答案均无效。

这是脚本:

<?php

$con = mysql_connect("XXXX", "name", "password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db("nameofdb",$con);

$musictable = "";

$sql = "GET * FROM matt";

$result = mysql_query($sql,$con);

while($row = mysql_fetch_object($result)) {

$id = $row->id;

$name = $row->name;

$update = $row->update;

$length = $row->length;

$size = $row->size;

$musictable .= "
<tr>
<td width=\"63%\">".$name."</td>
<td width=\"10%\">".$length." / ".$size."</td>
<td width=\"10%\"><a href=\"download.php?mp3=".$name."\">DOWLOAD</a></td>
<td width=\"17%\">|||||</td>
</tr>
";
}

?>

最佳答案

那是因为你的查询有误。

$sql = "GET * FROM matt";

必须可能成为

$sql = "SELECT * FROM matt";

获得警告的基本措施是

if (!$result)
die("mySQL error: ". mysql_error());

发出查询后。

关于php - 警告 : mysql_fetch_object(): supplied argument is not a valid MySQL result resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3923101/

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