Jump to content

[SOLVED] if(!isset($_GET['country_id'])){ - head hurts


aerophilia

Recommended Posts

Hi,

php newb here.

Quick "easy" question for you. It has been hurting my head this last hour.

 

What I want to do: if my URL has "?country_id=2" have my text appear on the page.

 

if(!isset($_GET['country_id'])){
		if($country_id=="2"){
			echo $europe_austria_txt;
		}
}

 

for further information here's "$europe_austria_text"

$europe_austria_txt="
	<br />
	Here will be some great text about the wonderful place they call Austria<br />
";

 

Link to comment
Share on other sites

1.) You dont need the ! sign. That makes the statement read the opposite to what you want.

2.) Unless you extracted $country_id from the URL previously, then that is unset.

3.) You can do it all with one if statement:

 

if(isset($_GET['country_id']) && $_GET['country_id'] == 2){
    echo $europe_austria_txt;
}

 

Also, if you enclose your string in double quotes, then you can use \n to make a new line, rather than spreading it across multiple lines:

 

$europe_austria_txt="\n<br />Here will be some great text about the wonderful place they call Austria<br />\n";

 

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.