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"


?>

Link to comment
Share on other sites

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

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.