Solved

IF evaluation not outputting as expected

Posted on 2006-06-20
3
213 Views
Last Modified: 2008-03-04
I am attempting to display some HTML conditionally depending on if it is during office hours. I'm sure that there is a more efficient way to write the following, but I'm not a PHP programmer, and I'm trying to write it as clearly as possible (for me).

The problem here is that the print function happens regardless of how the conditional statement is evaluated. The statement does evaluate as expected (if you print the output, True appears as 1 and false returns nothing), but the if statement prints regardless. I realize that the condition below doesn't make sense, but I wanted to ensure that it would output false in my test.

I need the print statement to happen only when the conditional statement evaluates to true.

<?php
// get current date
$current = getdate();
// turn it into strings
$current_hour = $current["hours"];
$current_minute = $current["minutes"];
$current_day = $current["wday"];

$switcher = ($current_hour < 7 && $current_hour < 17 && $current_day < 6);
if ($switcher == 1); {
print "<li><a href=# onclick=javascript:window.open('callme.html','callme','width=500,height=300,resizable=yes')><strong>Speak With an Advisor Now</strong></a></li>";
}
?>
0
Comment
Question by:BleuTango
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 500 total points
ID: 16942790
of course.. you have an empty if statement:
> if ($switcher == 1); {

just remove the ";"
0
 

Author Comment

by:BleuTango
ID: 16942823
LOL!
"It's so easy an idiot could do it... but there's never an idiot around when you need one. Bleu, get over here!"

Many thanks.
0
 
LVL 14

Expert Comment

by:ThG
ID: 16943158
you are welcome :-)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now