Hello, I've been looking around for a bit, but I can't seem to figure out why my query is apparently not working.
Here are the errors I'm getting:
"Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:...\film.php on line 11
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:...\film.php on line 12
Query that didn't work: SELECT COUNT(*) FROM movielist WHERE movie_id = 1
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:...\film.php:11) in C:...\includes\header.php on line 14"
Here's my code...
function checkFilmExists($id)
{
$q = 'SELECT COUNT(*) FROM movielist WHERE movie_id = '.$id;
$r = mysqli_query($dbc, $q); // <-- line 11
$row = mysqli_fetch_array($r);
if($row['COUNT(*)'] == 1)
{
return true;
}
else
{
echo 'Query that didn\'t work: ' . $q;
return false;
}
}
if( (isset($_GET['id'])) && (is_numeric($_GET['id'])) && (checkFilmExists($_GET['id'])) )
{
$id = $_GET['id'];
$filmInfo = getFilmInfo($id);
$error = false;
}
else
{
$error = true;
}
When I put the query that it spits out ("SELECT COUNT(*) FROM movielist WHERE movie_id = 1") into my database manually, it works properly and returns 1 or 0 depending if the record exists or not.
I'm using $dbc as my database connection on some other pages right now and it is working properly, so I'm not sure where the issue is.
If anyone could shed some light on my problem, I would be very grateful.