FairyBusiness
asked on
Why is my if statement not working?
Hi, I created a function that would only try to include a file if 'type' was in the url:
but its still trying to include it!! It should not get past the if statement!?!
anyone know whats going on?
http://gowiththemaster.com/tleithoff/index.php
// Determines which blurb should be included
function blurbs() {
if(isset($_GET['type'])) {
$blurb = $_GET['type'];
$blurb = "include " . $blurb . ".php;";
return $blurb;
}
else {
return false;
}
}
but its still trying to include it!! It should not get past the if statement!?!
anyone know whats going on?
http://gowiththemaster.com/tleithoff/index.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Those message means thast $_GET['type'] is empty: how pass you that value? With a form? Can you show us the form code?
ASKER
@Rik-Legger I am still getting the same message
@marqusG I am not using a form. I am just trying to include something according to the link that was clicked
@marqusG I am not using a form. I am just trying to include something according to the link that was clicked
ASKER
I changed it to this:
but still not luck
// Determines which blurb should be included
function blurbs() {
if(strlen($_GET['type']) > 0) {
$blurb = $_GET['type'];
$blurb = $blurb . ".php";
include $blurb;
}
else {
return false;
}
}
but still not luck
Then there is a value in $_GET['type'],
if you do like this you can see what it is:
if you do like this you can see what it is:
// Determines which blurb should be included
function blurbs() {
var_dump($_GET['type']); // Debugging
if(strlen($_GET['type']) > 0) {
$blurb = $_GET['type'];
$blurb = "include " . $blurb . ".php;";
return $blurb;
}
else {
return false;
}
}
ASKER
it returns NULL
I will change my code so that it can't be null and see that works
I will change my code so that it can't be null and see that works
ASKER
Geez its still not working!!
// Determines which blurb should be included
function blurbs() {
var_dump($_GET['type']); // Debugging
if((strlen($_GET['type']) > 0) && (($_GET['type']) != NULL)) {
$blurb = $_GET['type'];
$blurb = $blurb . ".php";
include $blurb;
}
else {
return false;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<?php
include 'header.php';
echo blurbs();
include 'footer.php';
?>
ASKER
oh wait that was the about.php page! You were right the index wasnt updated yet!