I am trying to select results from DB.
I am tried multiple query and prepared also.
but, both of them are not working to me :(
$query = "SELECT u.id FROM user u;";
$stmt = $mysqli->prepare($query);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$query = "SELECT position FROM company WHERE id = $id";
$stmt2 = $mysqli->prepare($query);
$stmt2->execute(); // error HERE (line 16)
$stmt_send->bind_result($position);
while($stmt->fetch()){
print $position;
}
Here is Error Code,
PHP Fatal error: Call to a member function execute() on a non-object in /var/www/test.php on line 16
May the same problem is asked here, but I cannot find any solver with this problem.
Please excuse my searching skill and thank you in advance.
sorry about late updating.
as I learn from this problem.
STMT is must closed before open new one even they have different name.
I solved this saved the first result into array and close it.
then, open new one with the array.
I think it makes redundance loop to make array at the first.
As I learn this problem, Prepared MySqli is so good if you need the same query changing parameters. O/W, just use simple MySqli.
Let me know, I understood wrong way.
Thanks.