473,770 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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["closeManTo r"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTo r-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 1736
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["closeManTo r"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTo r-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["closeManTo r"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTo r-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["closeManTo r"];
$timer = (int) date("H");
$minutter = (int) date("i");

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

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

and try var_dump(($clos eManTor-1) == $timer));
and var_dump(($minu tter >= 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["closeManTo r"];
$timer = (int) date("H");
$minutter = (int) date("i");

and in a switch statement:
if(($closeManTo r-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($somethi ng){
case 0:
echo "Something is nothing!";
break;
case 1:
echo "Something is 1!";
break;
case 1 && ($condOne=="TRU E"):
echo "Something is 1 and condOne is TRUE!";
break;
case 1 && ($condOne=="FAL SE"):
echo "Something is 1 and condOne is FALSE!";
break;
}

?>

Regards,

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

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

Similar topics

2
2823
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 Maintainer: Jan Roland Eriksson <rex@css.nu> ciwas stylesheet authoring FAQ v1.15 ______________________________________________________________________
0
1960
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: Jan Roland Eriksson <rex@css.nu> ciwas stylesheet authoring FAQ v1.16 ______________________________________________________________________
19
1488
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 literal using this way. Madhur Ahuja
14
1647
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 web site on the same server that allows visitors (around ten on average) to view the content of the internal database? As you can see there are several issues here; performance of server, security, broadband bandwidth, access etc. If this is...
24
2291
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 structure when something hit me and I wrote: // Function returns the greater or lesser numbers of two given numbers, // specified by a flag: 1 for greater (default), 0 for lesser
3
1912
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 code below. I was at the time quite satisfied with it, but reading stuff here has made me doubt it. Is this implementation valid? Is this implementation fast? The member TNode * Spread; I put it in there to
60
5062
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. consistently may make the code easier to understand for someone else, etc. Using "this." makes it immediately clear, for example, that the variable being referred to is a member of the same class and is not declared in the method as a local variable. ...
22
2301
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: http://groups.google.com/group/comp.arch/browse_frm/thread/24c40d42a04ee855 Anyway, here is the code snippet: #include <cstdio> #include <cstddef>
59
2530
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 objects, first call a class method to allocate the memory (typically alloc), and then call an initializer (typically starts with init). Some classes have class methods which perform this behind the scenes, especially classes that create cached,...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10037
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8931
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.