473,414 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

This makes no sense to me, simple comparisons.


I'm attempting to trigger things based on time.
I have one shop that has opening hours, closing hours and lunch hours store
as full hour values, integer, in MySQL.
I retrieve them, based on comparisons either shop is open, about to close or
actually closed.
When open, nothing particular is written, when closed, customer is informed
orders can't be executed, shop is closed.
But the last one, right about 15 minutes before closing time, should trigger
a special message to customers, but that comparison just won't work.

[code]
This is what I got:
$closeManTor = (int) $row["closeManTor"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTor-1) == $timer && $minutter >= 45)
return $almost_closed;
[code]

I tried to modify the last comparing statement to a simpler way,

if($closeManTor == $timer && $minutter >= 0)
return $almost_closed;

but even this fails.

I know for sure that I do compare integers, all have been checked using
gettype(), but that simple if statement just won't trigger anything.
Yes, I have assigned a value to $almost_closed, no problem there.

The switch works fine, as I have another if sentence in the same triggered
statement that works just fine. Connecting these two if-statements with an
if-else-if structure, didn't change anything at all, that's why the first
statement isn't shown here.

I really am getting grey hair here, rather, more then I do have ... and I'm
too young to get all grey haired already now ;-)

I'm sorry, but I really don't understand this one here.

/Andreas

--
Registeret Linux user #292411
Jul 17 '05 #1
5 1719
Andreas Paasch wrote:
I'm attempting to trigger things based on time.
I have one shop that has opening hours, closing hours and lunch hours store
as full hour values, integer, in MySQL.
I retrieve them, based on comparisons either shop is open, about to close or
actually closed.
When open, nothing particular is written, when closed, customer is informed
orders can't be executed, shop is closed.
But the last one, right about 15 minutes before closing time, should trigger
a special message to customers, but that comparison just won't work.

[code]
This is what I got:
$closeManTor = (int) $row["closeManTor"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTor-1) == $timer && $minutter >= 45)
return $almost_closed;
[code]

I tried to modify the last comparing statement to a simpler way,

if($closeManTor == $timer && $minutter >= 0)
return $almost_closed;

but even this fails.


Does your code behave the same way with constants?
[code]
/* ! */ ## changed lines
/* ! */ $closeManTor = 12;
/* ! */ $timer = 11;
/* ! */ $minutter = 53;
[code]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Pedro Graca wrote:
Andreas Paasch wrote:
I'm attempting to trigger things based on time.
I have one shop that has opening hours, closing hours and lunch hours
store as full hour values, integer, in MySQL.
I retrieve them, based on comparisons either shop is open, about to close
or actually closed.
When open, nothing particular is written, when closed, customer is
informed orders can't be executed, shop is closed.
But the last one, right about 15 minutes before closing time, should
trigger a special message to customers, but that comparison just won't
work.

[code]
This is what I got:
$closeManTor = (int) $row["closeManTor"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTor-1) == $timer && $minutter >= 45)
return $almost_closed;
[code]

I tried to modify the last comparing statement to a simpler way,

if($closeManTor == $timer && $minutter >= 0)
return $almost_closed;

but even this fails.


Does your code behave the same way with constants?
[code]
/* ! */ ## changed lines
/* ! */ $closeManTor = 12;
/* ! */ $timer = 11;
/* ! */ $minutter = 53;
[code]


Yes, but

I had another way to check it, and there it works fine, so the problem is
not in this comparison itself, but actually somewhere else.

Your hint about fixing the variables and then running it again, made me
rethink once again and led me to another error that needs to be tracked
down now, thanks for the hint :-)

/Andreas

--
Registeret Linux user #292411
Jul 17 '05 #3
Andreas Paasch wrote:
Yes, but

I had another way to check it, and there it works fine, so the problem is
not in this comparison itself, but actually somewhere else.
That's what I figured ...
Your hint about fixing the variables and then running it again, made me
rethink once again and led me to another error that needs to be tracked
down now, thanks for the hint :-)


I never expected it to work with those constants -- though it should :)

Happy bug hunting

/me loves bug hunting
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4
Hi Andreas!

On Mon, 16 Feb 2004 22:49:57 +0100, Andreas Paasch
<An*****@Paasch.Net> wrote:

I'm attempting to trigger things based on time.
I have one shop that has opening hours, closing hours and lunch hours store
as full hour values, integer, in MySQL.
I retrieve them, based on comparisons either shop is open, about to close or
actually closed.
When open, nothing particular is written, when closed, customer is informed
orders can't be executed, shop is closed.
But the last one, right about 15 minutes before closing time, should trigger
a special message to customers, but that comparison just won't work.

[code]
This is what I got:
$closeManTor = (int) $row["closeManTor"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTor-1) == $timer && $minutter >= 45)
try with brackets:

if((($closeManTor-1) == $timer) && ($minutter >= 45))

and try var_dump(($closeManTor-1) == $timer));
and var_dump(($minutter >= 45));

before.

HTH, Jochen
return $almost_closed;
[code]

I tried to modify the last comparing statement to a simpler way,

if($closeManTor == $timer && $minutter >= 0)
return $almost_closed;

but even this fails.

I know for sure that I do compare integers, all have been checked using
gettype(), but that simple if statement just won't trigger anything.
Yes, I have assigned a value to $almost_closed, no problem there.

The switch works fine, as I have another if sentence in the same triggered
statement that works just fine. Connecting these two if-statements with an
if-else-if structure, didn't change anything at all, that's why the first
statement isn't shown here.

I really am getting grey hair here, rather, more then I do have ... and I'm
too young to get all grey haired already now ;-)

I'm sorry, but I really don't understand this one here.

/Andreas


--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #5
Andreas Paasch wrote:
Pedro Graca wrote:

Andreas Paasch wrote:
I'm attempting to trigger things based on time.
I have one shop that has opening hours, closing hours and lunch hours
store as full hour values, integer, in MySQL.
I retrieve them, based on comparisons either shop is open, about to close
or actually closed.
When open, nothing particular is written, when closed, customer is
informed orders can't be executed, shop is closed.
But the last one, right about 15 minutes before closing time, should
trigger a special message to customers, but that comparison just won't
work.

[code]
This is what I got:
$closeManTor = (int) $row["closeManTor"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTor-1) == $timer && $minutter >= 45)
return $almost_closed;
[code]

I tried to modify the last comparing statement to a simpler way,

if($closeManTor == $timer && $minutter >= 0)
return $almost_closed;

but even this fails.


Does your code behave the same way with constants?
[code]
/* ! */ ## changed lines
/* ! */ $closeManTor = 12;
/* ! */ $timer = 11;
/* ! */ $minutter = 53;
[code]

Yes, but

I had another way to check it, and there it works fine, so the problem is
not in this comparison itself, but actually somewhere else.

Your hint about fixing the variables and then running it again, made me
rethink once again and led me to another error that needs to be tracked
down now, thanks for the hint :-)

/Andreas

Just throwin' this out there, but if your switch statement(s)
evaluate(s) to true, and you're got a "break:" nestled in there, you
might be getting a false positive, and your true positive isn't being
evaluated.

Point being, you might want to juggle the order in which your switch
conditions are evaluated.

Here's kinda what I'm getting at:

In the sample below, you won't ever see the bottom two cases, because
the second case evaluates as a match, and breaks out of the switch
statement.

<?php

$something = 1;
$condOne = "TRUE";

switch($something){
case 0:
echo "Something is nothing!";
break;
case 1:
echo "Something is 1!";
break;
case 1 && ($condOne=="TRUE"):
echo "Something is 1 and condOne is TRUE!";
break;
case 1 && ($condOne=="FALSE"):
echo "Something is 1 and condOne is FALSE!";
break;
}

?>

Regards,

- Dan
http://blog.dantripp.com/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer:...
19
by: madhur | last post by:
Hello char *a="str"; strcpy(a,"abc"); I have learnt that since "a" is a string literal, it might be allocated on read only memory on some implementations. Is it correct to modify a string...
14
by: John | last post by:
Hi We have an SBS2000 server which has an access database running internally, supporting around 20 users. The server is connected to a broadband connection. Is it viable for us to run an asp.net...
24
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
3
by: jesper | last post by:
I would like some feedback on this. A while back I was trying my hand at some pathfinding for a small game I was making. I did not know anything about it so I read some stuff and came up with the...
60
by: Dave | last post by:
I'm never quite sure whether to use "this." or not when referring to fields or properties in the same class. It obviously works just fine without it but sometimes I wonder if using this....
22
by: Chris Thomasson | last post by:
I am thinking about using this technique for all the "local" memory pools in a paticular multi-threaded allocator algorithm I invented. Some more info on that can be found here: ...
59
by: Kevin Walzer | last post by:
From the introduction to PyObjC, the Python-Objective-C bridge on Mac OS X: "As described in Objective-C for PyObjC users the creation of Objective-C objects is a two-stage process. To initialize...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.