首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我执行此脚本工作几秒钟后,出现内部错误500

问当我执行此脚本工作几秒钟后,出现内部错误500
EN

Stack Overflow用户
提问于 2014-11-05 19:23:52
回答 1查看 45关注 0票数 0
代码语言:javascript
复制
<?php
'require 'facebook.php';
include 'config.php';
//database connect
@mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
mysql_query("SET NAMES utf8");
//Create facebook application instance.
$facebook = new Facebook(array(
  'appId'  => $fb_app_id,
  'secret' => $fb_secret
));`$output = '';

   //get users and try liking
  $result = mysql_query("
      SELECT
         *
      FROM
         Likers 
   ");
`

    if($result){
      while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
         $m = $row['access_token'];
         $facebook->setAccessToken ($m);
         $id = trim($_POST ['postid']);
      try {
         $facebook->api("/".$id."/comments",'post',array('message' => $comment));
      }
      catch (FacebookApiException $e) {
            $output .= "<p>'". $row['name'] . "' failed to like.</p>";
         }
}
}
?>

当脚本开始执行时,在10秒或15秒内正常工作并执行输出

但在一段时间后给出了500内部服务器错误

我猜这是时间限制的问题,但我同时使用了时间间隔和时间限制代码,没有发生任何事情。

EN

回答 1

Stack Overflow用户

发布于 2014-11-05 19:30:00

它根本不能那样工作,修复你的错误。例如:

代码语言:javascript
复制
'require 'facebook.php'; (remove that sign at the beginning)
`$output = ''; put this in a new line and remove that sign at the beginning)
$comment is not defined

另外,你应该使用PDO,而不是mysql_connect。请查看PHP文档以了解这一点。

顺便说一句,看起来你想创建某种“自动生成器”或“自动注释器”。请记住,这在Facebook上是不允许的(显然)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26756009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档