2

I am using CURL and I am getting a 500 internal server error. I am not using the user agent option, could this be causing the issue?

This is the snippet

$current_url="http://localhost/mysite/entercode.php";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $current_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'variable1=abc&variable2=123');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
JohnP
  • 49,507
  • 13
  • 108
  • 140
temp-learn
  • 527
  • 2
  • 9
  • 31

2 Answers2

4

The same thing just happened to me.

A 500 Internal Server error when i tried to execute $ch = curl_init();. It turns out php curl wasn't installed on my server. I installed it and presto my code worked!

Check this out for how to install PHP CURL

Community
  • 1
  • 1
AlBeebe
  • 8,101
  • 3
  • 51
  • 65
0

entercode.php is throwing an error related to your input. I suggest you check the server error log. Your curl implementation is fine.

Steve Rukuts
  • 9,167
  • 3
  • 50
  • 72