Here’s the code
require_once 'functions.php';
require_once 'cfg.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error);
}
$query='SELECT * FROM cobra';
$result=$mysqli->prepare($query);
$result->execute();
$result->close();
echo array_values($result);
I am getting error after error. Initially I had the query part contained in a function, but kept running into all sorts of issues with variable scope for $mysqli.
The most recent error is: Fatal error: Call to a member function execute() on a non-object in …cobra/lib/distro.php on line 11
Line 11 is:
$result->execute();
I would like some background knowledge about the different ways to go about this. I am learning everything I can, but quickly approaching a deadline as well. Please help.
You need to check that
$resultis a validmysqli_stmtobject.