Solved

IF evaluation not outputting as expected

Posted on 2006-06-20
3
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

726 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