mysql_result()期望参数1是resource,boolean给定 [英] mysql_result() expects parameter 1 to be resource, boolean given
问题描述
下面的代码给我的错误:
The code below gives me the error:
mysql_result() expects parameter 1 to be resource, boolean given
我已经双重检查了我的数据库,并且所有表/字段名称都正确。
I have double checked my database and all table/field names are correct.
还有其他原因会导致这个错误吗?
Are there any other reasons why I would get this error?
if(isset($_GET['action']))
{
$action = $_GET['action'];
if($action == "edit")
{
$pid = $_GET['id'];
$query = "SELECT * FROM tbl_pages WHERE page_id = '$pid'";
$content = mysql_query($query);
$page_title = mysql_result($content, 0, 'page_title');
$page_content = mysql_result($content, 0, 'page_content');
echo "<form action=\"save.php\" method=\"post\">
Page Title: <input type=\"text\" name=\"pagetitle\" value=$page_title><br />
<textarea id=\"editor1\" type=\"text\" name=\"pagecontent\">$page_content</textarea>
<script type=\"text/javascript\">CKEDITOR.replace( 'editor1' );</script>
<input type=\"submit\">
</form>";
} else {
echo "<a href=\"editpage.php?action=edit&id=3\"><li>Setting up program/Adjusting preference</li></a>
<a href=\"editpage.php?action=edit&id=4\"><li>Choosing plugins</li></a>
<a href=\"editpage.php?action=edit&id=5\"><li>Basic Features/Functions</li></a>
<a href=\"editpage.php?action=edit&id=6\"><li>Creating a Drum Beat/Envelopes</li></a>
<a href=\"editpage.php?action=edit&id=7\"><li>Creating a Bass Wobble</li></a>
<a href=\"editpage.php?action=edit&id=8\"><li>Utilizing Plugins</li></a>
<a href=\"editpage.php?action=edit&id=9\"><li>Advanced Tools/Features</li></a>";
}
} else {
echo "<a href=\"editpage.php?action=edit&id=3\"><li>Setting up program/Adjusting preference</li></a>
<a href=\"editpage.php?action=edit&id=4\"><li>Choosing plugins</li></a>
<a href=\"editpage.php?action=edit&id=5\"><li>Basic Features/Functions</li></a>
<a href=\"editpage.php?action=edit&id=6\"><li>Creating a Drum Beat/Envelopes</li></a>
<a href=\"editpage.php?action=edit&id=7\"><li>Creating a Bass Wobble</li></a>
<a href=\"editpage.php?action=edit&id=8\"><li>Utilizing Plugins</li></a>
<a href=\"editpage.php?action=edit&id=9\"><li>Advanced Tools/Features</li></a>";
}
编辑:我双重检查连接和查询,出错了。我在页面的开头使用了非常类似的查询,除了使用mysqli_query,什么是mysqli的等效mysql_result?
I double checked the connection and query, still stuggling to find where ive gone wrong. I have used a very similar query at the start of the page except using mysqli_query, what is the equivalent mysql_result for mysqli? Does this make a difference?
感谢
推荐答案
do mysql_connect()
或者你忘记了吗?
Where do you do mysql_connect()
or did you forget to do that?
如果这不是问题, p>
If that is not the problem, change
$content = mysql_query($query);
加入
$content = mysql_query($query) or die(mysql_error());
并告诉我们您的错误是什么。
and tell us what your error is.
这篇关于mysql_result()期望参数1是resource,boolean给定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!