Problem with logical > (????)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

Problem with logical > (????)

Post by mparker1113 »

Hello:

I had to search for a very long time through eons(ish) of code to find that my code is saying:

Code: Select all

if( $granchildID > $highestID) 
{ 
         echo("grandkid advances at id = $grandchildID<br>");
         $highestID  = $grandchildID; 
}

else echo("grandkid of $grandchildID is not higher than $highestID<br>");
That $grandchildID is not greater than $highestID, even though what they print out from this scrippet is:
grandkid of 1022 is not higher than 1020
Now, how can this be, oh wise ones. We use scalar variables, right? Sigh, i just changed the code to add 0 to each variable in the logic test, with the same results.

Please help me look smart on this

>Mike[/quote]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

General Discussion is not the place to post coding problems.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if( $granchildID > $highestID)
d is missing.
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

figures -- thank you for babysitting me

Post by mparker1113 »

really -- thank you
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

volka wrote:
if( $granchildID > $highestID)
d is missing.
Good catch.

parker: make sure you have:

Code: Select all

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
So PHP tells you about these things.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Just make sure these settings are on your development machine. Always turn off display_errors for production environments.
Post Reply