NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP Fopen To Curl?? Help plz...

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 08-11-2010, 06:08 AM THREAD STARTER               #1 (permalink)
First Time Poster!
Join Date: Aug 2010
Posts: 1
rankwarrior is an unknown quantity at this point
 



PHP Fopen To Curl?? Help plz...


Hi everyone

I have recently changed servers, and one of my scripts is not functioning on the new server, as fopen is not enabled?

Is it possible to change the following code to use the CURL function instead?

Hope someone can help!
PHP Code:
<?php

$postToFileName 
'http://www.somesite.com/postfile.aspx';

$postArr = array(

'NM' => $row['Lead_Name'],

'EM' => $row['Lead_Email'],

'PH' => $row['Lead_Tel'],
????: NamePros.com http://www.namepros.com/programming/671664-php-fopen-to-curl-help-plz.html
????: NamePros.com http://www.namepros.com/showthread.php?t=671664

);

$opts = array(

'http'=>array(

'method' => 'POST',

'header' => "Content-type: application/x-www-form-urlencoded\r\n",

'content' => http_build_query($postArr)

)

);

$context stream_context_create($opts);

$fp fopen($postToFileName'r'false$context);

$returnedMessage '';

while (!
feof($fp)) {

$returnedMessage .= fgets($fp);

}

fclose($fp);

if (
$returnedMessage == '') {

$returnedMessage 'No Message';

} else if (
strlen($returnedMessage) > 250) {

$returnedMessage substr($returnedMessage,0,250);

}

$returnedMessage preg_replace("/[\r\n]/"''$returnedMessage);

$returnedMessage mysql_real_escape_string($returnedMessage$sql);

$q "UPDATE leads SET Data_Sent = '$returnedMessage' WHERE Lead_ID = $id";

mysql_query($q$sql);

array_push($leadsSent$id);

}

}

mysql_close($sql);

return 
$leadsSent;

}



?>
Last edited by Eric; 08-11-2010 at 06:40 AM.
rankwarrior is offline   Reply With Quote
Old 08-11-2010, 06:45 AM   #2 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
You can try:

PHP Code:
$ch curl_init($postToFileName);
????: NamePros.com http://www.namepros.com/showthread.php?t=671664
curl_setopt($chCURLOPT_POST1);
????: NamePros.com http://www.namepros.com/showthread.php?t=671664
curl_setopt($chCURLOPT_POSTFIELDShttp_build_query($postArr));
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_HEADER0);
$returnedMessage curl_exec($ch);
curl_close($ch); 
No need for the following code if the above works:
PHP Code:
$opts = array(

'http'=>array(

'method' => 'POST',

'header' => "Content-type: application/x-www-form-urlencoded\r\n",

'content' => http_build_query($postArr)

)

);

$context stream_context_create($opts);

$fp fopen($postToFileName'r'false$context);

$returnedMessage '';

while (!
feof($fp)) {

$returnedMessage .= fgets($fp);

}

fclose($fp); 
Eric is offline   Reply With Quote
Old 08-16-2010, 06:31 AM   #3 (permalink)
NamePros Member
Join Date: Jan 2010
Location: www
Posts: 185
ked38 has a spectacular aura aboutked38 has a spectacular aura about
 



Yes, make sure php.ini safe mode = off

,especially run curl stuffs.

(Hit the nail much in the past )
__________________
Like ActionScript 3 Much
Ked
ked38 is offline   Reply With Quote
Reply


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


 
All times are GMT -7. The time now is 02:37 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger