下面的代码给了我错误:
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 是什么?这有什么不同吗?
谢谢