I am using PHP and MySQL. I have the following PHP code:
$stmt = $this->db_connect()->prepare(
"SELECT P.`pool_id`, P.`pool_name`, PL.`player_id`, PL.`alias`, PP.`paid` "
."FROM `pool` AS P, `player_pool` AS PP, `players` AS PL "
."WHERE P.`sponsor` = ? "
."AND P.`pool_id` = PP.`pool_id` "
."AND PP.`player_id` = PL.`player_id` "
."ORDER BY P.`pool_name`, PL.`alias`;");
echo "stmt=".($stmt == null);
prepare() function seems to return null. This might happen due to an error in SQL, but most probably, if it works on your local machine, there is a problem with the database connection.
$this->db_connect() function if it reports connection errors. Separating the
db_connect() call from the
prepare() call might help to isolate the root cause:
$connection = $this->db_connect(); var_dump($connection); $stmt = $connection->prepare(...);