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


Getting a PHP syntax error when posting my site link on a facebook wall

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

http://247limosales.com/:语法错误,意外T_STRING,期望在/home/content/e/c/o/ecommphppro/html/247limosales/listsings.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 行

谢谢

在你的

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]}."'