curl_init not returning

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
ed4becky
Forum Newbie
Posts: 3
Joined: Wed Jan 14, 2009 10:41 am

curl_init not returning

Post by ed4becky »

Yes I am a newb (to PHP).

The following code:

Code: Select all

<?php
$request = 'http://amazon.com';
//echo $request . '<br><br>';
echo 'Starting <br>';
$response = file_get_contents_proxy($request, 'pac.wachovia.net', 80);
echo 'Leaving file_get_contents_proxy() <br>';
echo htmlspecialchars($response, ENT_QUOTES);
echo 'Done <br>';
 
function file_get_contents_proxy($szURL, $szProxy, $iProxyPort = 8080)
{
    echo 'Entering file_get_contents_proxy() <br>';
    $pCurl = curl_init();
 
    echo 'Completed curl_init() <br>';
    curl_setopt($pCurl, CURLOPT_URL, $szURL);
    curl_setopt($pCurl, CURLOPT_PROXY, $szProxy);
    curl_setopt($pCurl, CURLOPT_PROXYPORT, $iProxyPort);
    
   curl_setopt($pCurl, CURLOPT_FOLLOWLOCATION, true);
   curl_setopt($pCurl, CURLOPT_RETURNTRANSFER, true);
    echo 'Calling curl_exec() <br>';
 
    $output =  curl_exec($pCurl);
    curl_close($pCurl);
    return $output;
}
?>
 
I never get a return from curl_init(). That is to say:

Code: Select all

Starting
Entering file_get_contents_proxy()
Though the browser does say done.

Not sure where to go with this? I had a different error before I had curl properly installed.
This is on a windows XP box behind a firewall.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: curl_init not returning

Post by novice4eva »

Try enabling the error, maybe it will give us some hint

Code: Select all

 
       //TO ENABLE ERROR REPORTING
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
 
ed4becky
Forum Newbie
Posts: 3
Joined: Wed Jan 14, 2009 10:41 am

Re: curl_init not returning

Post by ed4becky »

Thanx, that showed me that the curl_init() is still not found.

I'll keep looking.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: curl_init not returning

Post by RobertGonzalez »

Have you restarted your web server to make sure the installation is actually being brought in?
ed4becky
Forum Newbie
Posts: 3
Joined: Wed Jan 14, 2009 10:41 am

Re: curl_init not returning

Post by ed4becky »

I had my extension dir set wrong
Post Reply