Try to search your question here, if you can't find : Ask Any Question Now ?

PHP / mysqli – Details page that carries record ID from link on main page giving error on $result variable

HomeCategory: stackoverflowPHP / mysqli – Details page that carries record ID from link on main page giving error on $result variable
Avatargaurav asked 3 months ago

I have a php/mysqli “properties.php” page that has a url table link to a “properties_details.php” page and am getting a fatal error on the details page.

I am using a remote mysql database on a godaddy hosting account. I am running PHP 5.6 and the typical plugins are selected. The properties display in a web page fine and I see the record id number in the url when I click a link (street) on the properties page and go to the detail page for the record.

My error is this:

“Fatal error: Call to undefined method mysqli_stmt::get_result() in /home/c52vd4xwknzn/public_html/properties_details.php on line 46.”

I added “// LINE 46 DIRECTLY BELOW —-” right above line 46 to identify it.

Here is my php code on the “properties_details.php” page where the error is:

<?Php
error_reporting(E_ALL);
ini_set("display_errors", 1);

// Collecting data from query string
$id=$_GET['id'];

// Checking data it is a number or not
if(!is_numeric($id)){
echo "Data Error";
exit;
}

// MySQL connection string
require "mysqli_connect.php";

$count="SELECT * FROM properties where id=?";

if($stmt = $dbc->prepare($count)){
$stmt->bind_param('i',$id);
$stmt->execute();

// LINE 46 DIRECTLY BELOW ----

$result=$stmt->get_result();
echo "No of records : ".$result->num_rows."<br>";
$row=$result->fetch_object();

echo "<table>";
echo "<tr ><td><b>Street</b></td><td>$row->street</td></tr>
<tr><td><b>City</b></td><td>$row->city</td></tr>
<tr><td><b>State</b></td><td>$row->state</td></tr>
<tr><td><b>Rent</b></td><td>$row->rent_due</td></tr>
<tr><td><b>Type</b></td><td>$row->type</td></tr>
";
echo "</table>";
}else{
echo $dbc->error;
}
?>

One the “properties_details.php” page, I expect to see all the listed fields for the one record that I selected on the “properties.php” page. Here is a link to the “properties.php” page:
http://cwdpreview.com/properties.php (there are 2 property records)

1 Answers
Best Answer
AvatarMannu answered 3 months ago
Your Answer

10 + 0 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com