警告:mysql_fetch_object():提供的参数不是有效的MySQL结果资源 [英] Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

查看:142
本文介绍了警告:mysql_fetch_object():提供的参数不是有效的MySQL结果资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在那里 当我尝试连接并将其从数据库中拉出时,出现以下错误:

Hell there when i try and connect to pull thing out of the database i get the following error:

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

此网站上的其他答案均无效.

None of the other answers on this site worked.

这是脚本:

<?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>
  ";
}

?>

推荐答案

那是因为您的查询错误.

That's because your query is wrong.

$sql = "GET * FROM matt";

可能必须成为

$sql = "SELECT * FROM matt";

关于此的警告的基本措施是

the basic measure to get warned about this is

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

发出查询后.

这篇关于警告:mysql_fetch_object():提供的参数不是有效的MySQL结果资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆