Jump to content

Recommended Posts

As a noob i'm sure there's good reason why this doesn't work but what i'd like to achieve is when a visitor opens a page it displays 'no organisation selected' and when they select one from a list (that coding works fine so i've left it out!) it puts ?orgname etc into the url...hope that makes sense!

....but this particular bit doesn't work!! Any suggestions most welcome, thanks!

 

<?php

if ($_GET['orgname']='') {

echo "no organisaton selected";

}

else {

echo $_GET['orgname'];

}

?>

Link to comment
https://forums.phpfreaks.com/topic/198776-basic-ifelse-problem/
Share on other sites

As that may be true, it still does not matter what order they are in. The expression is evaluated as a whole.

 

 

true || false = true

false || false = false

false || true = true

true || true = true

 

I don't see why the order they are called matters.

 

To explain why it doesn't work, it's because of this line:

 

if ($_GET['orgname']='') {

When comparing two values, you require at least 2 = signs. The statement you have above is ALWAYS true, because you're setting the value of $_GET['orgname'] to the empty string and that is always true. So there is really no comparison to be done.

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.