|
Posted by Michael Fesser on 06/19/07 13:24
..oO(James_sgp)
>Hi, I`m trying to write code that will check the contents of a
>variable ($distance) to see if it contains the value 'ft'. If it is
>true, I need it to divide the valiable $max_depth by 3.28; then write
>the variable into a MYSQL database. I have tried several different
>ways, but it seems that only the original (not divided by 3.28) value
>keeps getting put into the database. I`m using the line below to do
>the checking:
>
>if(strcmp($distance,"ft")==0) $max_depth=$max_depth/3.28;
This only checks if the value of $distance is the string 'ft':
if ($distance == 'ft') {...}
Obviously this is not enough if $distance contains a real value,
measured in foot, like '1000ft'. Try strpos() instead or a regular
expression.
Micha
Navigation:
[Reply to this message]
|