1

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)

Dharman
  • 21,838
  • 18
  • 57
  • 107
Mikes4
  • 11
  • 1
  • 1
    IMO, you're better off using PDO. Less verbose, fewer idiosyncrasies like this. And please upgrade, PHP 5.6 is end-of-life, as is PHP 7.0. Use 7.1 at a minimum. – miken32 Apr 11 '19 at 18:21
  • Thanks! So awesome to get help like this! : ) – Mikes4 Apr 11 '19 at 21:33
  • Thanks to you guys pointing me to other similar questions as mine, I found this which allowed my data to work: "I was getting this same error on my server - PHP 7.0 with the mysqlnd extension already enabled. Solution was for me (thanks to this page) was to deselect the mysqli extension and select nd_mysqli instead. NB - You may be able to access the extensions selector in your cPanel. (I access mine via the Select PHP Version option.)" I was able to make this change and it worked. However, I'm going to take your advice about changing to PDO. Thanks! – Mikes4 Apr 11 '19 at 21:38

0 Answers0