| 
	
 | 
 Posted by James_sgp on 06/20/07 02:24 
On Jun 19, 9:24 pm, Michael Fesser <neti...@gmx.de> wrote: 
> .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 
 
Micha, 
 
  Ok, my problem doesn`t seem to be my if statement.  As I can display 
the result and it is correct!  The problem is that the variable 
$max_depth isn`t updated when it is written into the database, hence 
the original value is always there.
 
[Back to original message] 
 |