Mysqli prepared stmt - using object multiple times?
Hello all,
I am using mysqli prepared statements and I have moved to my first medium sized project which i'm having a problem with objects now. I have a broad understanding of the objects and instantiating an object (i think).
Here it is:
I have a page that i include in the pages using the database 'connectvars.php:
PHP Code:
$mysqli=new new mysqli('localhost', 'uname', 'pass', 'db');
I also have a page 'functions.php' which i have all my php functions that i include:
PHP Code:
function getUsers(){
global $mysqli;
$stmt=$mysqli->prepare(..........prepared statement etc.
}
function getPhoneNumbers(){
global $mysqli;
$stmt=$mysqli->prepare(..........prepared statement etc.
}
function getPictures(){
global $mysqli;
$stmt=$mysqli->prepare(..........prepared statement etc.
}
Finally on my index page, if i call multiple functions on the same page, i get an object error, saying "Call to a member function bind_param() on a non-object", i've removed my $stmt->bind_param() and used error reporting and it's saying that the $stmt=$mysqli->prepare() failed.
I have a hunch it is because i'm trying to use the same instance of $mysqli at the same time? Am i close?
Thanks for the help!