I'm trying to use some simple code that's used elsewhere to access content from a MySQL database.
Code...
$rec_sessions_array = array();
$sql = "SELECT member_id FROM " . TABLE_PREFIX . "rec_sessions WHERE course_id = $course_id";
$result = mysql_query($sql, $db);
if($result && mysql_num_rows($result) > 0){
while ($row = mysql_fetch_assoc($result)) {
$rec_sessions_array[] = $row['member_id'];
}
}
I keep getting "Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in [path to my script] on line 367". Line 367 is the $result = mysql_query($sql, $db);
from above.
When I echo $sql
it's correct. When I run that query directly via PHP MyAdmin, it works fine.
Any ideas?
Also, before you say anything about getting away from mysql functions, I know. I'm just trying to augment something that already exists.