Jump to content

Value check resets value


pthes

Recommended Posts

I have come across the strangest error in one of my sites today. I checking to see what hour of the day it is and then use it as the default value of a dropdown box. The problem is that if the hour is "08" or "09" the value gets set to "00".

 

I created simple code to test.

 

 

<?php  $val = 01; ?>

<?php if ($val == 01) { echo $val."  what is this!!";} else {echo "should be 1";} ?>

 

<?php  $val = 02; ?>

<?php if ($val == 02) { echo $val."  what is this!!";} else {echo "should be 2";} ?>

 

 

<?php  $val = 08; ?>

<?php if ($val == 08){ echo $val."  what is this!!";} else {echo "should be 8";} ?>

 

<?php  $val = 09; ?>

<?php if ($val == 09) { echo $val."  what is this!!";} else {echo "should be 9";} ?>

 

 

This is what I get

 

1 what is this!! 2 what is this!! 0 what is this!! 0 what is this!!

 

It looks like when $val == 08 is executed it sets $val to 0 !!

 

I'm using PHP 5

 

If anyone has seen this before please let me know what's going on.

 

Thanks.

 

Link to comment
Share on other sites

Tagged like that because of quick copy and paste to create the script. As for 01,02,03 not being numbers, that how it comes out of date/time field in mySQL. Also, if they're not numbers why does it work perfectly for all numbers from 00 to 23 except for 08 and 09?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.