I'm currently setting up a development environment on Ubuntu for an existing working php / mysql website.
When attempting to generate a page, I get the following error:
PHP Fatal error: Uncaught Error: Call to a member function execute() on boolean in /var/www/html/dev.example.com/class/wtd.data.class.php:55\nStack trace:\n
#0 /var/www/html/dev.example.com/class/rollcage.class.php(295): wtdMySQL->select('vehicles LEFT J...', 'vehicle', 'CASE WHEN vehic...', '1 AND vehicles....', 'results', 'vehicles.vehicl...', 'vehicleModel,ve...')\n
#1 /var/www/html/dev.example.com/layouts/roll-cage-selector.php(3): rollcage->getRollCageModels('Motorsport', '', 'Live')\n
#2 /var/www/html/dev.example.com/index.php(562): include('/var/www/html/d...')\n#3 {main}\n thrown in /var/www/html/dev.example.com/class/wtd.data.class.php on line 55
The code that generates this error looks like this:
function select($table, $prefix=NULL, $columns="*", $where=NULL, $return="results", $orderby=NULL, $group=NULL, $limit=NULL){
global $errors;
$this->set_charset("utf8");
$sql = "SELECT {$columns} FROM {$table}";
if($where) $sql .= " WHERE {$where}";
if($group) $sql .= " GROUP BY {$group}";
if($orderby) $sql .= " ORDER BY {$orderby}";
if($limit) $sql .= " LIMIT {$limit}";
if($errors==3){
print "<div class='error'>$sql</div>";
}
$prepare = $this->prepare($sql);
$prepare->execute();
$prepare->store_result();
The SQL is generated correctly and returns a single row. A var_dump of $prepare shows this:
object(mysqli_stmt)#3 (10) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(0) ["field_count"]=> int(28) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) }
As this works on the live server, I'm guessing this could be environmental, but am I missing anything obvious?
Any pointers appreciated.