Jump to content

[SOLVED] If variable is empty - Ignore lines in PHP ???


a.beam.reach

Recommended Posts

I am wondering how to ignore lines of PHP code if the applicable variable is empty.

 

For example in the code below. . . .  if the variable $r is empty. . ..  I would like the entire line:

echo "http://www.mysite.com/images/$r/1"

to be ignored.

 

Can you tell that I am very novice!!!!  I am learning though.

 

<?

// SET GALLERY OPTIONS HERE
// -----------------------
// Set Gallery options by editing this text:
$q =$_POST['q'];
$r =$_POST['r'];


echo "http://www.mysite.com/images/$q/1"
echo "http://www.mysite.com/images/$r/1"


?>

Thank you LazyJones and xenophobia. . ..

 

I did not get a chance to try your suggestion xenophobia. . . . as I had already tried the suggestion of LazyJones.  It worked great!

 

I did notice the suggestions were slightly different.  Guess there is more than one way to skin a cat!

 

Thanks to you both.

 

Trevor

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.