This code doesn't seem to work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

This code doesn't seem to work

Post by legend986 »

I'm trying to retrieve the contents from a website but it keeps displaying "array()" and the page but it doesn't display the $req_info value. What mistake am I doing?

Code: Select all

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://asn.cymru.com/cgi-bin/whois.cgi");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "action=do_whois&family=ipv4&method_whois=whois&bulk_paste=72.14.253.99&submit_paste=Submit");
$result = curl_exec ($ch);
//echo $result;
$pattern = "/[1-9]{1,9}\s\s\s[|]\s[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/";
$req_info = array();
preg_match($pattern,$result,$req_info);
print_r($req_info);
curl_close ($ch); 
?>
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

something wrong with your pattern matching. Better place to ask is in the Regex forums: viewforum.php?f=38
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Ok Solved it myself... I should've enabled the Return transfer
Post Reply