-1

编辑:我的客户在这里给了我错误的细节是正确的代码这是产生问题的区域的一部分。完整的代码太大,但可以在这里找到 http://pastebin.com/9506yzGh 这让我很困惑,在我的虚拟机(测试场)上,这段代码有效!!证明 http://socialneko.koding.com/现在但是在 godaddy 托管它没有。http://socialneko.com/

解析错误:语法错误,第 297 行 /home/content/21/11408921/html/index.php 中的意外 $end

  <?php
$ads = array(
"<a href='http://3ds-explore.com'><img src='http://puu.sh/391aC.png'></a>",
"<a href='http://socialpixel.heliohost.org'><img src='/image/socialpixel.png'></a>",
"<a href='http://strike.koding.com'>DSiStrike</a>",
"<a href='http://3dsar7.koding.com'><img src='/image/remixed.png'></a>",
"<a href='http://l09.heliohost.org'><img src='/image/l09.png'></a>"
);

print_r($ads[array_rand($ads)]);
?></center>

<span style="position:absolute;top:60px;left:180px;font-size:10px;color:gray;letter-spacing:-1px;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;">
<?php echo $database->getNumMembers(); ?> members and growing!
</span>

<br><center><a href="http://mobile.twitter.com/sosharuneko"><img src="/image/follow.png"></a></center><br>

<?php include("footer.php"); ?>

</body>
</html>

页脚.php:

<hr>
<div class="footer" style="font-size:10px;color:grey"> <center>
    Total members: <?php echo $database->getNumMembers(); ?><br>
    Newcomer: <?php
        $getnewcomer = mysqli_query(db(), "SELECT username FROM users ORDER BY id DESC");
        $newcomer = mysqli_fetch_row($getnewcomer);
        if($session->logged_in){
            echo "<a href='/user/".strtolower($newcomer[0])."'>$newcomer[0]</a>";
        } else {
            echo $newcomer[0];
        }
    ?>
    <p> <div class="copyright"> This website is &copy;2012-2013 SocialNeko.<br> All rights reserved.<p> About :: <a href="/guide/terms.php">Terms</a></center> </div><p>
</div>

db() 函数

$db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
if($db->connect_errno > 0){
die("<p><b>It looks like we can't connect to the database.</b><br>A team of highly trained monkeys has been dispatched to deal with this situation.<p>If you see them, show them this information:<br>[" . $db->connect_error . "]<br>Refreshing in 8 seconds. <meta http-equiv='REFRESH' content='8;url='>");
//die('Unable to connect to database ');
}

function db()
{
global $db;
global $host;
global $db_username;
global $db_pass;
global $db_name;
if (!$db) {
$db = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
}

return $db;
}
4

2 回答 2

1

这只是一个标准的“肘部润滑脂”调试问题:根据我的经验,行号通常对这个错误没有用,因为它给出了 EOF ln # 并且根据其中一条评论,它通常是一个未闭合的括号、括号等。

我发现的一个 hacky 但富有成效的方法是exit;从脚本中的第一个代码块开始,如果它执行到该点而没有错误,exit;则从该点删除,并把它放得更远. 最终,您应该在逐行调试中遇到错误。

IE:

 <?php
$ads = array(
"<a href='http://3ds-explore.com'><img src='http://puu.sh/391aC.png'></a>",
"<a href='http://socialpixel.heliohost.org'><img src='/image/socialpixel.png'></a>",
"<a href='http://strike.koding.com'>DSiStrike</a>",
"<a href='http://3dsar7.koding.com'><img src='/image/remixed.png'></a>",
"<a href='http://l09.heliohost.org'><img src='/image/l09.png'></a>"
);

// Start Cutoff: 1st try to make sure code is executing up to this point:
exit;
// End Cut Off -- if it executed up to here - move this cutoff block further down, 
// until you can approximate where the error is occuring


print_r($ads[array_rand($ads)]);
?></center>

<span style="position:absolute;top:60px;left:180px;font-size:10px;color:gray;letter-spacing:-1px;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;">
<?php echo $database->getNumMembers(); ?> members and growing!
</span>
于 2013-07-14T05:34:53.983 回答
1

我相信 Go Daddy 默认关闭了 php 短标签 - short_open_tag = off.

所以第 78 行

<? }else{ ?>

80

<? } ?>

92

<? } ?>

286

<? }else{ ?>

290

<? } ?>

不解析。

最好的办法是将它们全部更改为<?php.

您也可以short_open_tag = on在 php.ini 或<?php ini_set(‘short_open_tag’,’1′); ?>页面顶部进行更改,但不推荐。

于 2013-07-14T05:48:38.900 回答