EchoFool Posted June 29, 2009 Share Posted June 29, 2009 I have a simple curl script which sends a post to a website, but although it 100% works, my "or die( show ever) " part of the script still displays which makes no sense.... this is my script: <?php $curl_handle = curl_init (); curl_setopt ($curl_handle, CURLOPT_URL,$row['IncentiveUrl']); curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl_handle, CURLOPT_POST, 1); curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, 'UserID='.$UserID); $response = curl_exec ($curl_handle) or die ("There has been an error connecting to your POST method site."); curl_close ($curl_handle); ?> It works perfect but it always shows: There has been an error connecting to your POST method site. Why might this be ? Link to comment https://forums.phpfreaks.com/topic/164138-problems-with-curl/ Share on other sites More sharing options...
rhodesa Posted June 29, 2009 Share Posted June 29, 2009 does your page you post to print anything out? if not, it will run the die() statement. instead, after you execute it, check curl_error() or check the HTTP Response Code with curl_getinfo() Link to comment https://forums.phpfreaks.com/topic/164138-problems-with-curl/#findComment-865866 Share on other sites More sharing options...
EchoFool Posted June 29, 2009 Author Share Posted June 29, 2009 Well i changed: $response = curl_exec ($curl_handle) or die ("There has been an error connecting to your POST method site."); To: $response = curl_exec ($curl_handle) or die ("The error was: ". curl_error($curl_handle)); and got this in return : The error was: couldn't connect to host Yes it did connect and send the post as the script that recieved the POST processed it.. =/ Link to comment https://forums.phpfreaks.com/topic/164138-problems-with-curl/#findComment-865871 Share on other sites More sharing options...
rhodesa Posted June 29, 2009 Share Posted June 29, 2009 the code should look like this: $response = curl_exec ($curl_handle); if($error = curl_error($curl_handle)) die ("The error was: ". $error); Link to comment https://forums.phpfreaks.com/topic/164138-problems-with-curl/#findComment-865883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.