Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 12th Dec 2011, 06:31 PM   #1
Grouchy Old Geezer
War Room Member
 
Kirk Ward's Avatar
 
Join Date: 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
Default
Help with PHP "If" statement needed
Share on: 
fb share twitter share gplus share more share

Hello,

I am placing the following code in a wordpress post template.

It works fine with either of the lines when used not as a variable or called in an if statement. However, when I add the if statement, and call the variables, the page does not load (dreaded white page syndrome).

Can anyone tell me what I have missed, or how to correct the code?

Code:
<?php
$future_date = get_the_date('U');
$pub_date = strtotime('+1 month', $future_date);
$date_alt_1 = <<< EOF
   <?php _e('Postcards will start being released on', 'themename'); ?> <font color="blue"><?php echo date('M j, Y', $pub_date); ?></font>
EOF;
$date_alt_2 = <<< EOF
   <?php _e('Posted by', 'themename'); ?> <?php the_author_posts_link(); ?> <?php _e('on', 'themename'); ?> <?php the_time('F j, Y'); ?>
EOF;
?>

<?php
if ($pub_date > time()) 
{
   echo $date_alt_1;
else
   echo $date_alt_2;
}
?>
Many thanks!

"We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
Kirk Ward is offline  
Unread 12th Dec 2011, 07:50 PM   #2
PHP ninja
War Room Member
 
kevbo22's Avatar
 
Join Date: 2011
Location: Denver
Posts: 124
Thanks: 13
Thanked 27 Times in 25 Posts
Default
Re: Help with PHP "If" statement needed
Share on: 
fb share twitter share gplus share more share

It is your "else" statement

echo $date_alt_1; } // missing the close
else { // your missing the open

The best path to prosperity is free market capitalism!
kevbo22 is offline  
The Following User Says Thank You to kevbo22 For This Useful Post:
Unread 12th Dec 2011, 07:53 PM   #3
Grouchy Old Geezer
War Room Member
 
Kirk Ward's Avatar
 
Join Date: 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
Default
Re: Help with PHP "If" statement needed
Share on: 
fb share twitter share gplus share more share

Is this better?

Code:
<?php
if ( > time()) 
{
   echo ;
} else {
   echo ;
}
?>

"We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
Kirk Ward is offline  
Unread 12th Dec 2011, 07:56 PM   #4
PHP ninja
War Room Member
 
kevbo22's Avatar
 
Join Date: 2011
Location: Denver
Posts: 124
Thanks: 13
Thanked 27 Times in 25 Posts
Default
Re: Help with PHP "If" statement needed
Share on: 
fb share twitter share gplus share more share

Yep. Looks good. Here is what you want:
Code:
 <?php
 = get_the_date('U');
 = strtotime('+1 month', );
 = <<< EOF
   <?php _e('Postcards will start being released on', 'themename'); ?> <font color="blue"><?php echo date('M j, Y', ); ?></font>
EOF;
 = <<< EOF
   <?php _e('Posted by', 'themename'); ?> <?php the_author_posts_link(); ?> <?php _e('on', 'themename'); ?> <?php the_time('F j, Y'); ?>
EOF;
?>

<?php
if ( > time()) 
{
   echo  ; }
else{
   echo  ;
}
?>
Add the data to your if statement
kevbo22 is offline  
The Following User Says Thank You to kevbo22 For This Useful Post:
Unread 12th Dec 2011, 10:27 PM   #5
Grouchy Old Geezer
War Room Member
 
Kirk Ward's Avatar
 
Join Date: 2006
Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
Default
Re: Help with PHP "If" statement needed
Share on: 
fb share twitter share gplus share more share

Thanks much ....

The php is coded so that it doesn't break my page any more, but the echo is not printing to the screen.

Am I making a mistake trying to put php into that <<<EOF thingy? I've tested by doing an echo of a text string, and it shows properly. Maybe something with trying to include php and html code in a variable?

"We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
Kirk Ward is offline  
Closed Thread


Bookmarks

Tags
needed, php, statement


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:08 AM.