while ($row = mysql_fetch_array($results)) {
$results_array[$row['post_id']] = $row;
$arr = array($row[2] => $row[3]);
$location = trim($arr[cp_check_where_to_show_video]);
$video = trim($arr[cp_embed_video]);
echo $video;
if($location=='Video of the Day')
{
echo $location."\n";
echo "---";
echo $video;
echo "---";
}
}
Output:
Video Text
Video of the Day
-------
NULL
Here’s the thing. Suppose I have the code above, the ‘videos’ were derived from the database. So far, i’m having no problem with my queries until I added the if statement.
The first echo outputs the expected results, but inside the if statement “video” becomes NULL. I could get in the if statement and output anything except for the $video.
Could someone please tell what went wrong or could possibly be wrong with the statements above? Weird.
(Really a comment, but adding code so putting in here)
Debug solution 1: Add error reporting; just before the while, add
and see what that give you.
Debug solution 2:
Could be a case of “Editor inserted wierd character that I can’t see”. Suggestion is to TOTALLY delete the lines inside the if statement (select entire line, hit delete), as well as the lines that reference $video, and retype them manually (no copy / paste). Hidden characters do happen – and the only solution I can think of.