I'm having a really weird problem with my MySQL database. To make sure I wasn't make a dumb mistake, I tested it without the database...
$Content = 'Hello World';
// $Content = '';
switch ($Content)
{
case '':
echo 'No Content 1';
break;
default:
echo 'Content 1';
echo $Content;
echo '<br><br>';
break;
}
It works. When content equals 'Hello World' it echoes "Content 1." When I set it to $Content = '', it echoes "No Content 1."
But when I delete the first two lines and insert "Hello World" in my database, something funny happens.
Actually, it works correctly at first. But when I delete the content from the database, it still displays "Content 1," even though there's no database content. (It doesn't echo the value for $Content.)
I checked the database to see if there might be a 0 (zero) in the cell, but there isn't. There isn't even a simple space.
On a whim, I added the value 0 to my switch:
switch ($Content)
{
case '':
case 0:
echo 'No Content I';
break;
default:
echo 'Content I<br><br>';
echo $Content;
break;
}
Now it does just the opposite, display "No Content" whether there's content in the database or not.
Am I making some simple mistake? I upgraded MAMP a couple days ago, so I wondered if it might be some kind of software bug.
ON EDIT: I Googled for more information and found this solution...
if ($Content != 0) {
echo "true";
echo $Content;
} else {
echo "false";
echo $Content;
}
However, it doesn't work for me, either; it returns "false" where there's content in the database or not.