Hi,
for some reason, in the following code $result is always empty. yet if I reun the query directly on the database (in phpmyadmin) it returns a value.
can anyone tell me what I'm missing?
Thanks in advance!
for some reason, in the following code $result is always empty. yet if I reun the query directly on the database (in phpmyadmin) it returns a value.
can anyone tell me what I'm missing?
Code:
<?php
class Page {
public function getContent($page_id) {
/* Create a new mysqli object with database connection parameters */
$mysqli = new mysqli('localhost', 'root', '', 'clg');
if(mysqli_connect_errno()) {
echo "Connection Failed: " . mysqli_connect_errno();
exit();
}
/* Create a prepared statement */
if($stmt = $mysqli -> prepare("SELECT content FROM content WHERE id > ?"))
{
/* Bind parameters
s - string, b - boolean, i - int, etc */
$stmt -> bind_param("s", $page_id);
/* Execute it */
$stmt -> execute();
/* Bind results */
$stmt -> bind_result($result);
$stmt -> fetch();
echo $page_id;
print_r($stmt);
echo mysqli_stmt_affected_rows($stmt);
/* Close statement */
$stmt -> close();
}
/* Close connection */
$mysqli -> close();
}
}
$page = new Page;
$page->getContent(1);
Comment