I am following a tutorial on PHP. The code given below is to get the pages listed in the database to display to the webpage. I already fixed the problem and the code works fine.
When I used a NULL value for both variables, the $getSubj would work, and display the subject in the content page. $getPage would default to "Select A Subject or Page to Edit...". In the tutorial, of course, it worked.
I attempted to change the value to '' but that gave me an error. I changed it to " ". That failed as well. Finally, I tried ' ', and this worked. After two days of puzzling, and wonderment, I was able to move on. I changed both the value for $getPage & $getSubj for consistency. PHP doesn't seem to mind.
My question is why did ' ' finally do the trick, whereas NULL, "" and '' all failed? Why did PHP initially behave the way it did prior to replacing the values? BTW, '' is two single quotes with no space. Thank you in advance for your feedback.
Here is the function:
Here is the code to print that printsPHP Code:
$getSubj = funcGetSubID($_GET['subj']);
$getPage = ' '; //replaced NULL with ' '
$getSubj = ' '; // replaced NULL with ' '
$getPage = funcGetPageID($_GET['page']);
$getSubj = NULL;
$getPage = NULL;
the subjects and pages to navigation:
if(($getSubj != null) && ($getPage != null))
echo "Select A Subject or Page to Edit...";
<?php echo $getPage['content']; ?>