Instruct ICC wrote:
Date: Thu, 25 Oct 2007 09:43:14 +0800
From: ronald@xxxxxxxxx
To: php-general@xxxxxxxxxxxxx
Subject: 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);
Thanks! 1st solution did not work for me, but the second one did.
I still have a problem with it. It prints the info to the page. Can I
suppress this somehow?
bye
Ronald
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php