TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   yet another curl question.... (http://www.talkphp.com/general/3009-yet-another-curl-question.html)

Jenski 06-26-2008 09:43 AM

yet another curl question....
 
ok, I have this code:

Code:

$ch = curl_init('http://www.google.co.uk'); // the target
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return the page
$result = curl_exec($ch); // executing the cURL
curl_close($ch); // Closing connection
echo $result;

Which I got from here:
TalkPHP - cURL Basics

Any ideas why I would end up with a blank screen? with no errors?
Do I need to configure something with the curl library or something?
I'm using php 5
Thanks
Jen

Wildhoney 06-26-2008 12:14 PM

Do you normally see errors on your development server? I imagine it is causing errors, but you're not displaying them, and possibly logging them. You need to enable the cURL module in order for it to work.

First you may wish to enable the displaying of errors. Find the following 2 lines and change them to what they are below. Those are the only 2 lines, or so I think.

Code:

error_reporting  =  E_ALL
display_errors = On

And then to enable cURL, acquire the DLL/SO (depending on OS) from PHP.net, and last of all uncomment the following line, again in php.ini:

Code:

extension=php_curl.dll

Jenski 06-30-2008 12:54 PM

Thanks for your reply. I've double checked the php.ini file and it is already loading the curl extention, I have also enabled logging, and still comes up with a blank screen.
It obviously recognises the curl function, just acts as if it doesnt know what to do with it.

drewbee 06-30-2008 03:32 PM

Try adding a trailing slash after the url. Curl acts funny with some server setups.

PHP Code:

$ch curl_init('http://www.google.co.uk/'); // the target
curl_setopt($chCURLOPT_RETURNTRANSFER1); // return the page
$result curl_exec($ch); // executing the cURL
curl_close($ch); // Closing connection
echo $result


Jenski 07-01-2008 09:43 AM

still no avail :-(
is there another setting in the php ini file that could be preventing it? Safe Mode or something?

Jenski 07-01-2008 10:16 AM

I just tried
Code:

$exists = function_exists  ('curl_init');
echo $exists;

and it returns '1'.
I'm running out of ideas...

Jenski 07-01-2008 10:17 AM

Also when I do phpinfo();
it comes up with:
Code:

curl
cURL support                enabled
cURL Information        libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1

I don't know what's stopping it

Jenski 07-01-2008 10:25 AM

HA! FOUND IT!!!!!

I didn't configure our networks Proxy Server in the options!!

If anybody else has this problem here is the solution:
Code:

$proxy="<proxy_ip>:<proxy_port_no>";
$ch = curl_init('http://www.google.co.uk/'); // the target
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return the page
$result = curl_exec($ch); // executing the cURL
curl_close($ch); // Closing connection
echo $result;

Hope this helps somebody

Jen

codefreek 07-01-2008 10:36 AM

Quote:

Originally Posted by Wildhoney (Post 16032)
Do you normally see errors on your development server? I imagine it is causing errors, but you're not displaying them, and possibly logging them. You need to enable the cURL module in order for it to work.

First you may wish to enable the displaying of errors. Find the following 2 lines and change them to what they are below. Those are the only 2 lines, or so I think.

Code:

error_reporting  =  E_ALL
display_errors = On

And then to enable cURL, acquire the DLL/SO (depending on OS) from PHP.net, and last of all uncomment the following line, again in php.ini:

Code:

extension=php_curl.dll

PHP Code:

error_reporting(E_ALL & ~E_NOTICE); 

PHP: error_reporting - Manual
PHP: cURL - Manual


All times are GMT. The time now is 02:06 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0