I have the following code
$sqlSubscription = "SELECT `user_id` FROM subscriptions WHERE `user_id` = '".$user_id."' and `course_id` = 'calculus_1'";
$subscriptionResult = mysql_query($sqlSubscription);
if($subscriptionResult === FALSE) {
die(mysql_error()); // temp error handling
}
while ($rows = mysql_fetch_assoc($subscriptionResult))
{
$user_id = $rows['user_id'];
$course_id = $rows['course_id'];
if($user_id==1 && $course_id="calculus_1")
{
//do some work
}
}
I'm getting the error Notice: Undefined index: course_id
The line that causes the error is in the while statement $course_id = $rows['course_id'];
The strange part is that I can select from where both user and course ids match, and there aren't any errors doing something simple like an echo, but when I add this while statement to verify that both the user and course_ids match a certain rule before outputting data I get this error.
Here is an export of the PHP Arrays through phpMyAdmin
<?php
/**
* Export to PHP Array plugin for PHPMyAdmin
* @version 0.2b
*/
//
// Database `test`
//
// `escholars`.`subscriptions`
$subscriptions = array(
array('user_id' => 'test','course_id' => 'calculus_1','start_date' => '2013-09-12','end_date' => '2013-09-28')
);
Any ideas?
Thanks