I am trying to use the curl method and keep getting a 500 error. Although when I run a test php script that only has curl it will work smoothly.
This is the code that works:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $goto_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "id_of=".$id."&sqlreq=".$sqlreq);
// execute post
$result = curl_exec($ch);
// close connection
curl_close($ch);
And on my other file I try this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $goto_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "id_of=".$id."&sqlreq=".$sqreq);
$result = curl_exec($ch);
// close connection
curl_close($ch);
The difference between the files is that there is data being processed in the second file. I thought maybe I needed to close my sql connection but then that didn't work. The code seems to work. I'm not sure what's wrong. Also note when I comment out curl_exec($ch) then no error occurs.
Any ideas? Thanks.
curl_setopt($ch, CURLOPT_POSTFIELDS, "id_of=".$id."&sqlreq=".$sqreq);
should be
curl_setopt($ch, CURLOPT_POSTFIELDS, "id_of=".$id."&sqlreq=".$sqlreq);
you have typoo there. sqreq -> sqlreq.