TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-26-2008, 10:43 AM   #1 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default 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
Jenski is offline  
Reply With Quote
Old 06-26-2008, 01:14 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,600
Thanks: 72
Wildhoney is on a distinguished road
Default

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
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-30-2008, 01:54 PM   #3 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default

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.
Jenski is offline  
Reply With Quote
Old 06-30-2008, 04:32 PM   #4 (permalink)
The Acquainted
 
drewbee's Avatar
 
Join Date: May 2008
Posts: 175
Thanks: 9
drewbee is on a distinguished road
Default

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
__________________
There are No Stupid Questions. But there a LOT of Inquisitive Idiots.
Send a message via AIM to drewbee
drewbee is offline  
Reply With Quote
Old 07-01-2008, 10:43 AM   #5 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default

still no avail
is there another setting in the php ini file that could be preventing it? Safe Mode or something?
Jenski is offline  
Reply With Quote
Old 07-01-2008, 11:16 AM   #6 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default

I just tried
Code:
$exists = function_exists  ('curl_init');
echo $exists;
and it returns '1'.
I'm running out of ideas...
Jenski is offline  
Reply With Quote
Old 07-01-2008, 11:17 AM   #7 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default

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 is offline  
Reply With Quote
Old 07-01-2008, 11:25 AM   #8 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 15
Thanks: 0
Jenski is on a distinguished road
Default

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
Jenski is offline  
Reply With Quote
Old 07-01-2008, 11:36 AM   #9 (permalink)
Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 452
Thanks: 228
codefreek is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
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
__________________
inquisitive
1. Eager to acquire knowledge.
2. Too curious; overly interested; nosy.
codefreek is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:09 AM.

 
     

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