Home › Forums › Back End › mysqli_fetch_assoc() expects parameter 1 to be mysqli_result error › Re: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result error
June 2, 2013 at 2:52 pm
#137367
LaurelBrittany
Participant
I ran the code as you described as being correct in your first comment and got this:
“This code has failed “
<form method="post" action="<?php $_SERVER;?>">
<?PHP
// Get the ID and Table name into variables
$id = $_GET;
$table = $_GET;
$title = $_GET;
include('includes/dbc_admin.php');
$sql = "SELECT * FROM $table where id = '$id'";
$result = mysql_query($sql);
if($result) {
while($row=mysql_fetch_assoc($result))
{
echo '<div>ID</div><input style="hidden" name="id" value="'.$id.'"><br/><br/>';
echo '<div>Table</div><input style="hidden" name="table" value="'.$table.'"><br/><br/>';
echo '<div>Title</div><textarea name="title" width="500">'.$row.'</textarea><br/><br/>';
echo '<div>Message</div><textarea name="message" width="500" height="300">'.$row.'</textarea>';
}
}
else {
echo 'This code has failed';
}
?>
<input type="submit" name="Submit_Update" value="Update">
</form>
Check out this Pen!