Ok, there arnt any error messages anymore.
I want it to say if u have a pet :
Error, you cannot make another pet!
And if you dont the stuff to create it.
So i did that code above which says if havepet is set to one it shows Sorry you cannont create another pet! and the else to show if its not 1 the stuff to make the pet. Right now all it shows is the stuff to make the pet even if its set to 1, whats wrong?
Quick easy error, php xperts help!
Moderator: General Moderators
As a test check the variable has a value in before using it in your if statement and then see if its equal to 1:
Regards,
Code: Select all
...
session_start();
if(isset($havepet))
{
if($havepet==1) {
echo "You already have a pet, you cannot create another!";
}else{
// do your other stuff.
}
} else {
echo "havepet not set!";
var_dump($havepet);
}
...No, just that the variable may not contain a value of 1, your if statement is matching something which obviously is'nt a value of 1.
As a test, echo out $havepet before the if (after you start your session) and see what it's value is:
What is the value of this variable ?
Regards,
As a test, echo out $havepet before the if (after you start your session) and see what it's value is:
Code: Select all
echo "havepet value = ".$havepet."<br />\n";Regards,
Well, sorry to post this so late was on vacation, each persons value is different. The value is either 1 or 0 but when they fill out a form on a sperate page it sets the value to one. Mine was set to one but still thinks it's 0. Maby I need to get thier id or something otherwise it checks no row wihich would mean it would be 0, which is defualt.