I am trying to run the following script (unsuccessfully):
$variables = $db->query("SELECT * FROM table1 WHERE Session_ID = '$sess1'");
while($row = $variables->fetch()) {
//FETCH DATA
$id= $row["ID"];
$info = $db->query("SELECT * FROM table2 WHERE ID = $id");
while($row2 = $info->fetch()) {
$name = $row2["FNAME"]." ".$row2["LNAME"]; }
$phone = $row2["PHONE"];
}
//SEND CUSTOMER EMAIL
require("../email/email.php");
}
this returns the error: Fatal error: Call to a member function fetch() on a non-object in...
While I am able to "solve" the problem, it is ugly. Essentially I have to make several calls ahead of the one I'm trying below (which in theory should work).
Any ideas?