[PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
Can somebody explain me why is this happening? $value = 12.3; $number = intval($value); echo Number: $number, Value: $valuebr; // echoes: Number: 12, Value: 12.3 if ($number != $value) { echo Bad; } else { echo Good; // echoes Good!! } The previous should be echoing Bad. (I

Re: [PHP] problem with intval and !=

2003-10-23 Thread Curt Zirzow
* Thus wrote Cesar Cordovez ([EMAIL PROTECTED]): Can somebody explain me why is this happening? $value = 12.3; $number = intval($value); echo Number: $number, Value: $valuebr; // echoes: Number: 12, Value: 12.3 I'm guessing you wondering why the .3 is removed. Thats because 12.3 isn't

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
What versio of php? I get Bad (which is good ;) Cesar Cordovez wrote: Can somebody explain me why is this happening? $value = 12.3; $number = intval($value); echo Number: $number, Value: $valuebr; // echoes: Number: 12, Value: 12.3 if ($number != $value) { echo Bad; } else { echo Good;

Re: [PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
Curt: My fault! You are right, but thats not what I want. $value comes from a form filled by a user. I want $value to be an integer. Not a float. So if the user types 12.3 the system has to send an error msg. Therefore the procedure. By-the-way, Im using PHP 4.3.3 (on windows XP

Re: [PHP] problem with intval and !=

2003-10-23 Thread Curt Zirzow
* Thus wrote Cesar Cordovez ([EMAIL PROTECTED]): Curt: My fault! You are right, but thats not what I want. $value comes from a form filled by a user. I want $value to be an integer. Not a float. So if the user types 12.3 the system has to send an error msg. Yeah, after reading merek's

Re: [PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
The other purpose of this procedure is if the user types 12asdasd into $value, $number will be assigned 12 so $value and $number are not the same, meaning $value is not a number. Which is correct, but the procedure is not working correctly in PHP when it should. (It works in c, c++, fortran

Re: [PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
This is getting weird by the minute. I changed the script: if ($number != $value) { echo Bad; } else { echo Good; // echoes Good!! } to: ($number != $value) ($number !== $value) ($number === $value) and I get the Good stuff... At this point, I think I have to change the

Re: [PHP] problem with intval and !=

2003-10-23 Thread Andrea Pinnisi
why don't you use this?? http://it.php.net/manual/it/function.is-integer.php Cesar Cordovez ha scritto: This is getting weird by the minute. I changed the script: if ($number != $value) { echo Bad; } else { echo Good; // echoes Good!! } to: ($number != $value) ($number !==

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
This should be reported as a bug. I tried few searches and I got Warning: mysql_fetch_array(): 9 is not a valid MySQL result resource in /local/Web/sites/php-bugs-web/search.php on line 182 on bugs.php.net Cesar Cordovez wrote: This is getting weird by the minute. I changed the script: if

Re: [PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
Because is_integer(12thisisnotanumber) retuns true. Andrea Pinnisi wrote: why don't you use this?? http://it.php.net/manual/it/function.is-integer.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 11:41, Cesar Cordovez wrote: Because is_integer(12thisisnotanumber) retuns true. Not for me it doesn't. Returns false. Prolly because it's a string. Even the following returns false for me: is_integer(12) Cheers, Rob. --

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 11:21, Cesar Cordovez wrote: At this point, I think I have to change the procedure. This is not good. Any sugestions on how to now if the user types an integer number in a field? Here's a really simple way: if( ereg( '^[[:space:]]*[[:digit:]]+[[:space:]]*',

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 11:51, Robert Cummings wrote: On Thu, 2003-10-23 at 11:21, Cesar Cordovez wrote: At this point, I think I have to change the procedure. This is not good. Any sugestions on how to now if the user types an integer number in a field? Here's a really simple

Re: [PHP] problem with intval and !=

2003-10-23 Thread Cesar Cordovez
Sorry, typo, this is what I meant, !is_integer(12thisisnotanumber) retuns true. but also, is_integer(12) return false. therefore, is_integer(12) return true. So, how can I check if what ever the user writes is an integer or not, knowing that he will write it in a string field. Any how, I

Re: [PHP] problem with intval and !=

2003-10-23 Thread Curt Zirzow
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]): This should be reported as a bug. I tried few searches and I got Warning: mysql_fetch_array(): 9 is not a valid MySQL result resource in /local/Web/sites/php-bugs-web/search.php on line 182 The search seems to work now, what did you

Re: [PHP] problem with intval and !=

2003-10-23 Thread Greg Beaver
Hello all, http://www.php.net/is_numeric is the function you are looking for. No need for fancy regexps. Regards, Greg -- phpDocumentor http://www.phpdoc.org Cesar Cordovez wrote: Sorry, typo, this is what I meant, !is_integer(12thisisnotanumber) retuns true. but also, is_integer(12) return

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
Status: All Return only bugs in categories: Scripting Engine Problem Return bugs with operating system: windows But it is ok now. Curt Zirzow wrote: * Thus wrote Marek Kilimajer ([EMAIL PROTECTED]): This should be reported as a bug. I tried few searches and I got Warning: mysql_fetch_array():

Re: [PHP] problem with intval and !=

2003-10-23 Thread Jordan S. Jones
Cesar, You can take a look into is_numeric () (http://www.php.net/is_numeric). It will tell you whether the value is a number or a numeric string, but it will also return true if the value is a float. However, at that point you know your working with the right type of variable. Jordan S.

Re: [PHP] problem with intval and !=

2003-10-23 Thread John W. Holmes
Greg Beaver wrote: http://www.php.net/is_numeric is the function you are looking for. No need for fancy regexps. The OP is looking for an integer, but is_numeric() will return true for float values and also for numbers in scientific notation. So 12.3 and 12E3 will be TRUE. The original

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
These are all workarounds around the real problem. If php gets it wrong fix php. Robert Sedlacek wrote: On Thu, 23 Oct 2003 11:59:44 -0400, Cesar Cordovez wrote: So, how can I check if what ever the user writes is an integer or not, knowing that he will write it in a string field. Idea:

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 12:28, Greg Beaver wrote: Hello all, http://www.php.net/is_numeric is the function you are looking for. No need for fancy regexps. Sorry, that doesn't cut it. He want's integers not floats, and I'm also sure he doesn't want exponential notation to pass either.

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 12:43, Marek Kilimajer wrote: These are all workarounds around the real problem. If php gets it wrong fix php. Could you explain how PHP has it wrong? Rob. -- .. | InterJinn Application Framework -

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 12:41, John W. Holmes wrote: Greg Beaver wrote: http://www.php.net/is_numeric is the function you are looking for. No need for fancy regexps. The OP is looking for an integer, but is_numeric() will return true for float values and also for numbers in

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
This echoes out Bad on my LAMP server as it should, but Good on Cesar's windows server: $value = 12.3; $number = intval($value); echo Number: $number, Value: $valuebr; // echoes: Number: 12, Value: 12.3 if ($number != $value) { echo Bad; } else { echo Good; // echoes Good!! }

Re: [PHP] problem with intval and !=

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 13:01, Marek Kilimajer wrote: This echoes out Bad on my LAMP server as it should, but Good on Cesar's windows server: Aaaah how true. I wasn't following this much earlier so I don't know if he is using the most up to date version, in which case it may already be fixed.

Re: [PHP] problem with intval [CONCLUSION]

2003-10-23 Thread Cesar Cordovez
Everybody: This problem solved. It is not PHP's fault, It is mine. When I fixed some problems that I thought where non intrusive in this problem, everything started working as a charm. Here is the finished function, it is part of a class called xValidate. function integer($msg, $prompt,

Re: [PHP] problem with intval and !=

2003-10-23 Thread Marek Kilimajer
I got the error again: http://bugs.php.net/search.php?search_for=boolean=0limit=10order_by=direction=ASCcmd=displaystatus=Allbug_type%5B%5D=Scripting+Engine+problemphp_os=windowsphpver=assign=author_email=bug_age=0 Curt Zirzow wrote: * Thus wrote Marek Kilimajer ([EMAIL PROTECTED]): This should

Re: [PHP] problem with intval and !=

2003-10-23 Thread Curt Zirzow
* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]): I got the error again: http://bugs.php.net/search.php?search_for=boolean=0limit=10order_by=direction=ASCcmd=displaystatus=Allbug_type%5B%5D=Scripting+Engine+problemphp_os=windowsphpver=assign=author_email=bug_age=0 That reminds me of the time