I seem to be having an odd issue when trying to switch my code over to my live server. It works on my local WAMP server without fail, however on my live server, when I try to pull information from my database and put it into a table, I get the error in the question title in my error_log.
This is the code that causes the error:
<?php
$query = 'SELECT * FROM APPLICATIONS';
$stmt = $dbConnection->prepare($query);
$stmt->execute();
$result = $stmt->get_result();
$num_applications = $result->num_rows;
?>
specifically : $result = $stmt->get_result();
I contacted my Server Host to make sure the correct version of PHP was installed. They got me to add the following to my php.ini file:
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so
I did so, but it hasn't fixed the issue. They then told me it had to be my code. From the documents I've read, and experiencing it on my local server, the code seems to be correct, perhaps I need an outside perspective though.
Here is the table where I call data:
<table class="table table-hover table-striped table-bordered table-condensed">
<tr>
<th style="text-align:center;">Application ID</th>
<th style="text-align:center;">Last Name</th>
<th style="text-align:center;">First Name</th>
<th style="text-align:center;">Organization</th>
<th style="text-align:center;">Title</th>
<th style="text-align:center;">Link to View</th>
</tr>
<?php
for ($i = 0; $i < $num_applications; $i++) {
$row = $result->fetch_assoc();
$id = $row['ID'];
$last_name = $row['LAST_NAME'];
$first_name = $row['FIRST_NAME'];
$organization = $row['ORGANIZATION'];
$title = $row['TITLE'];
$link = '<a href="../view_application.php?id='.$id.'"><i class="icon-external-link" style="color:#1122CC;"></i></a>';
echo
"<tr>
<td style='text-align:center;'>$id</td>
<td style='text-align:center;'>$last_name</td>
<td style='text-align:center;'>$first_name</td>
<td style='text-align:center;'>$organization</td>
<td style='text-align:center;'>$title</td>
<td style='text-align:center;'>$link</td>
</tr>";
}
?>
</table>
Commenter asked where $dbConnection was defined, earlier in the file:
<?php
$db_host = 'localhost';
$db_port = '3306';
$db_username = 'user';
$db_password = 'password';
$db_primaryDatabase = 'dbname';
// Connect to the database, using the predefined database variables in /assets/repository/mysql.php
$dbConnection = new mysqli($db_host, $db_username, $db_password, $db_primaryDatabase);
// If there are errors (if the no# of errors is > 1), print out the error and cancel loading the page via exit();
if (mysqli_connect_errno()) {
printf("Could not connect to MySQL databse: %s
", mysqli_connect_error());
exit();
}
?>
just to ask, are you sure that the extensions you've added have been loaded ?
Maybe the problem is there, or not. Hope that help.
mysqli_stmt :: get_result
is available only with mysqlnd package (php extension).
(php5-mysqlnd) is not in (php5-mysql)