Jump to content

isset!!! nope not setting so


burtybob

Recommended Posts

I have a piece of code sayin

$staff1 = $_REQUEST['staff1']; // also tried with $_GET and $_POST but neither worked for me
if (isset($staff1)) {
echo "hello";
}

And i am not 'setting' the variable so why is it echoing the hello (i am going to turn the actual true statement into a usefull thing but i thought echoing something i would be able to see if it is working)

 

Please can anyone help as i have spent the last week looking thorugh this code to make sure nothing is passed to the variable to be able to set it.

Link to comment
Share on other sites

OOPs Programming lol!!!! (very bad pun)

 

Now i am checking to see if its empty and im using same code as before but instead of isset() im using empty () and even when its got data it still echos hello!!! any ideas?

I even tried manually giveing the variable a value in the code and still it echos!!!

 

Please? :)

 

Grr i even tell the code to echo if its empty and it actually echos a value!

Link to comment
Share on other sites

Why don't you echo the var itself and see what it contains?

 

$staff1 = $_REQUEST['staff1'];

echo $staff1;

 

You may also use

echo int($staff1);

 

etc.

 

If you read my post i did try this also mmmvomit i have tried the isset() method and as someone pointed out the variable does set! Even if it is $staff='' still becomes 'set'

Link to comment
Share on other sites

You missed the line of code I added.

 

print_r($staff1);

 

Sorry you are right i did miss that piece of code and it now doesnt echo when the variable isnt set, thank you can i please ask what the print_r actually does because in the php manual it says its to do with arrays is this true?

 

Thank you!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.