[PHP-DB] Comparison with formatted numbers

2002-07-30 Thread Terry Romine

I've run into a sticky case where my query is failing (PHP4.x/MySQL).

I have a table where the price value is imported from an external 
source, so I can't change it on the fly, and they embed thousands 
seperators (in my case ','). When I try to do a query such as .. where 
price = '25' .. if finds values that meet or exceed that value 
(returns some in the range of 2,500,000. I gather that it is failing 
because of the comma (the price field contains values of '2,500,000').

Is there a function that I can use to force the price format to integer 
before/during the query? Or would it work if I did a number_format on 
the test value? ie: '.. where price = '200,000' ..'

Help would be appreciated.

Terry


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Comparison with formatted numbers

2002-07-30 Thread leo g. divinagracia iii

try the good ol' SETTYPE function to set the variable type from string to
numeric and visa versa...

http://www.php.net/manual/en/function.settype.php

Terry Romine wrote:

 I've run into a sticky case where my query is failing (PHP4.x/MySQL).

 I have a table where the price value is imported from an external
 source, so I can't change it on the fly, and they embed thousands
 seperators (in my case ','). When I try to do a query such as .. where
 price = '25' .. if finds values that meet or exceed that value
 (returns some in the range of 2,500,000. I gather that it is failing
 because of the comma (the price field contains values of '2,500,000').

 Is there a function that I can use to force the price format to integer
 before/during the query? Or would it work if I did a number_format on
 the test value? ie: '.. where price = '200,000' ..'

 Help would be appreciated.

 Terry

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Leo G. Divinagracia III
[EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php