This question already has an answer here:
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>";
}
EDIT: 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?
Thanks
</div>
Where do you do mysql_connect()
or did you forget to do that?
If that is not the problem, change
$content = mysql_query($query);
into
$content = mysql_query($query) or die(mysql_error());
and tell us what your error is.