2011-11-28 66 views
2

我正在使用CURL,我得到500内部服务器错误。我没有使用用户代理选项,这是否会导致问题?使用CURL,给500内部服务器错误

这是段

$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); 
+1

检查您的错误日志。请告诉我们'entercode.php'的来源 - 这是错误所在。 – DaveRandom

+1

另外,你缺少'curl_setopt($ ch,CURLOPT_POST,1);' – DaveRandom

回答

0

entercode.php抛出关系到你的输入错误。我建议你检查服务器错误日志。你的卷曲实现很好。

4

同样的事情发生在我身上。

500内部服务器错误,当我试图执行$ch = curl_init();。事实证明,我的服务器上没有安装php curl。我安装它,并presto我的代码工作!

检查此为how to install PHP CURL