在Facebook墙上发布我的站点链接时出现PHP语法错误

时间:2012-06-28 20:58:32

标签: php facebook syntax hyperlink facebook-comments

当我尝试在Facebook上发布http://www.247limosales.com评论时,我收到以下消息:

http://247limosales.com/ :语法错误,意外T_STRING,期待','或';'在/home/content/e/c/o/ecommphppro/html/247limosales/listings.php第462行

我检查了我的PHP代码,没关系,我在实际网站上也没有问题 本身,它正确地生成HTML,我不明白为什么facebook正在给予 这个错误。即使我转到网站上的“查看代码”,我也看不到像上面那样的错误

以下是第462行的代码:

// See if we have a unique hit      
$hitquery = mysql_query("SELECT * FROM listinghits WHERE hitip='" . $_SERVER["REMOTE_ADDR"] . "' AND adid='" . $adid . "' LIMIT 1");

  if (!$hitquery)

  { echo mysql_error(); }
  if (mysql_num_rows($hitquery)==0)
  {
    $hitquery = mysql_query("INSERT INTO listinghits (hitid, date, hitip, adid) VALUES ('', CURDATE(), '" . $_SERVER["REMOTE_ADDR"] . "', '" . $adid . "')");
    if (!$hitquery)
    { echo mysql_error(); }
  }

最后一行是第62行

谢谢

1 个答案:

答案 0 :(得分:0)

它将是adid字符串中的'或'(使用mysql_real_escape_string($ adid) 要么 发生的事情是$ _SERVER [REMOTE_ADDR]中的句点被视为连接,因此它变为:

select * from table where htip='".128.10.50.125."'" and it is breaking the string as it is expecting a ' or ".

尝试:

select * from table where htip='".{$_SERVER[REMOTE_ADDR]}."'