RE: [PHP] system command

From: Date: Thu, 25 Oct 2007 03:19:08 +0000
Subject: RE: [PHP] system command
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-263630@lists.php.net to get a copy of this message
> Date: Thu, 25 Oct 2007 09:43:14 +0800 > From: ronald@elmit.com > To: php-general@lists.php.net > Subject: [PHP] system command > > I tried: > > $a=$_SERVER["REMOTE_ADDR"]; > echo "<p>REMOTE_ADDR=$a<br>"; > if($a="192.168.250.108") { > $a="61.64.101.101"; > } > > > $aa=system('lynx -dump > http://api.hostip.info/country.php?ip=$a',$location); > echo "<p>a=$a<br>aa=$aa<br>location=$location<br>"; > > $aa=system('lynx -dump > > http://api.hostip.info/country.php?ip=61.64.101.101',$location); > echo "<p>a=$a<br>aa=$aa<br>location=$location<br>"; > > > I get: > > REMOTE_ADDR=192.168.250.108 > XX > > a=61.64.101.101 > aa=XX > location=0 > TW > > a=61.64.101.101 > aa=TW > location=0 > > > as you can see, if I put the IP address in, I get the right answer (TW). > > What am I doing wrong? > > bye > > Ronald Use double quotes to get the value of $a or else you get the literal string "$a". $aa=system("lynx -dump http://api.hostip.info/country.php?ip=$a",$location); or $aa=system('lynx -dump http://api.hostip.info/country.php?ip='.$a,$location); _________________________________________________________________ Peek-a-boo FREE Tricks & Treats for You! http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us

« previous php.general (#263630) next »