下面的代码给出了错误:
mysql_result() expects parameter 1 to be resource, boolean given
我已经仔细检查了我的数据库,并且所有表/字段名称都是正确的。
我还有其他原因会收到此错误吗?
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是什么?这有什么不同吗?
由于
答案 0 :(得分:1)
你在哪做mysql_connect()
或者你忘了这样做?
如果不是问题,请更改
$content = mysql_query($query);
进入
$content = mysql_query($query) or die(mysql_error());
告诉我们你的错误是什么。