I have a set of functions:
One creates the connection, the others do different kinds of database interaction using that function.
I am retrieving the error;
Call to undefined method mysqli::execute()
this is telling me that I am failing to send the object through correctly, I have done some research but failed to find examples;
<?php
function con(){
$mysqli = new Mysqli("localhost","user","pass","image_blog");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}else{
return $mysqli;
}};
function getAll(){
$mysqli = con();
$stmt = $mysqli->prepare("SELECT * FROM posts");
$stmt = $mysqli->execute(); <--- ERROR HERE
$stmt = $mysqli->get_result();
$stmt = $mysqli->close();
while($row = mysqli_fetch_array($stmt, MYSQL_ASSOC)) {
echo "Username: " . $row["image"];
echo "Username: " . $row["title"];
echo "Username: " . $row["text"];
echo "Username: " . $row["up"];
echo "Username: " . $row["date"];
}
};
function anotherFunction(){
}
function yetAnotherFunction(){
}