Ok, now I am not sure why I cannot get this output into a variable so I can place it into a database table field. Any help would be greatly appreciated. <?php
/* Check client info and register */ if (getenv(HTTP_X_FORWARDED_FOR)){ $ipaddy = getenv(HTTP_X_FORWARDED_FOR); } else { $ipaddy = getenv(REMOTE_ADDR); $host = gethostbyaddr($REMOTE_ADDR); } /* Start looking up users IP vs. WHOIS database for logging */ $nipaddy = ""; function message($msg){ echo "$msg"; flush(); } function arin($ipaddy){ $server = "whois.arin.net"; if (!$ipaddy = gethostbyname($ipaddy)) $msg .= "Can't IP Whois without an IP address."; else{ if (! $sock = fsockopen($server, 43, &$num, &$error, 20)){ unset($sock); $msg .= "Timed-out connecting to $server (port 43)"; } else{ fputs($sock, "$ipaddy\n"); while (!feof($sock)) $buffer .= fgets($sock, 10240); fclose($sock); } if (eregi("RIPE.NET", $buffer)) $nextServer = "whois.ripe.net"; else if (eregi("whois.apnic.net", $buffer)) $nextServer = "whois.apnic.net"; else if (eregi("nic.ad.jp", $buffer)){ $nextServer = "whois.nic.ad.jp"; #/e suppresses Japanese character output from JPNIC $extra = "/e"; } else if (eregi("whois.registro.br", $buffer)) $nextServer = "whois.registro.br"; if($nextServer){ $buffer = ""; message("Deferred to specific whois server: $nextServer...<br><br>"); if(! $sock = fsockopen($nextServer, 43, &$num, &$error, 10)){ unset($sock); $msg .= "Timed-out connecting to $nextServer (port 43)"; } else{ fputs($sock, "$ipaddy$extra\n"); while (!feof($sock)) $buffer .= fgets($sock, 10240); fclose($sock); } } $buffer = str_replace(" ", " ", $buffer); $msg .= nl2br($buffer); } message($msg); } /* Place results into a var */ $whois = arin($ipaddy); // Right now if this is here it will show in two areas of the screen /* Start putting the data into the database table */ $table = "sessions"; $sql_insert = "INSERT INTO $table (ipaddy,whois) VALUES ('$ipaddy','$whois')"; $result = @mysql_query($sql_insert,$dbh) or die(MYSQL_ERROR()); // No error but what gets entered for the var $whois is arin(66.56.34.32) ?> <?php echo $ipaddy; ?> <?php echo arin($ipaddy; ?> // These results should be placed in $whois which is empty <?php echo $whois; ?> // This returns arin(65.44.33.23) which is wrong Any help on this would be appreciated! Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php