[advanced search]
Results from the most recent live auction are here.
23 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-29-2008, 07:11 AM   · #1
Hossam
New Member
 
Trader Rating: (0)
Join Date: Apr 2008
Posts: 2
NP$: 0.00 (Donate)
Hossam is an unknown quantity at this point
Help! CURL alternative to fopen - revisited

Hello!

There is already a thread that was created that touched on this issue, but it was locked.

My host provider is no longer allowing fopen and fgets command calls due to security issues and CURL was suggested as an alternative method to achieve the same results.

Here is a snippet of the code which is giving errors in my php script:

Code:
if($address!='') { $fp = fopen($address,"r"); $i=0; while($i<1000){ $html_data.=fgets($fp); $i++; }


I know this is probably a very simple fix, but my knowledge of CURL is limited at best, any help would be appreciated! Thank you.


Please register or log-in into NamePros to hide ads

Last edited by Hossam : 04-29-2008 at 07:17 AM.
Hossam is offline   Reply With Quote
Old 04-29-2008, 08:44 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 681.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
www.php.net/curl

Very easy to use!
Daniel is offline   Reply With Quote
Old 04-29-2008, 10:17 AM   · #3
Hossam
New Member
 
Trader Rating: (0)
Join Date: Apr 2008
Posts: 2
NP$: 0.00 (Donate)
Hossam is an unknown quantity at this point
Darn, i tried this but I don't get the result as the prior script

PHP Code:
if($address!='')
{    
                
$fp = curl_init();
                
curl_setopt($fp, CURLOPT_URL, $address);
                
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
                
curl_setopt($fp, CURLOPT_FORBID_REUSE, true);
                
curl_setopt($fp, CURLOPT_FRESH_CONNECT, true);
                
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, 3);
                
curl_setopt($fp, CURLOPT_TIMEOUT, 10);
                
curl_setopt($fp, CURLOPT_HTTPHEADER, array('Connection: close'));

                
$html_data = curl_exec($fp);
}


The page renders blank! Any suggestions?

Last edited by Hossam : 04-29-2008 at 11:37 AM.
Hossam is offline   Reply With Quote
Old 04-30-2008, 12:20 AM   · #4
xrvel
xrvel is cruel :-)
 
xrvel's Avatar
 
Location: Indonesia
Trader Rating: (24)
Join Date: Nov 2007
Posts: 889
NP$: 713.06 (Donate)
xrvel is a splendid one to beholdxrvel is a splendid one to beholdxrvel is a splendid one to beholdxrvel is a splendid one to beholdxrvel is a splendid one to beholdxrvel is a splendid one to beholdxrvel is a splendid one to behold
This should work
PHP Code:
$curlurl = 'http://something.com';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlurl);
curl_setopt($ch, CURLOPT_REFERER, $curlurl);
curl_setopt($ch, CURLOPT_USERAGENT, getenv('HTTP_USER_AGENT'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$curlresult = curl_exec($ch);
curl_close($ch);

echo(
$curlresult);
__________________
Xrvel
Signature #2
xrvel is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

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
Forum Jump


Site Sponsors
Proof is in the Parking Get Your Site Linked at LinkedKeywords.com
Advertise your business at NamePros
All times are GMT -7. The time now is 12:05 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0