Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 分析错误…can';你根本找不到吗?(第86行)_Php_Syntax_Syntax Error - Fatal编程技术网

Php 分析错误…can';你根本找不到吗?(第86行)

Php 分析错误…can';你根本找不到吗?(第86行),php,syntax,syntax-error,Php,Syntax,Syntax Error,我是这个编码游戏的新手,但在这段代码中找不到我的语法/解析错误。错误是说第86行是代码的结尾。我曾试图添加括号,但运气不佳。这可能是一个基本的问题,但我已经为此挣扎了一段时间,所以我想我应该在这里把它拍下来,看看我是否能得到一些明确的指导,不再只是扔东西进去 <html> <head> <title>View Guestbook</title> <link rel="stylesheet" type="text/css" hr

我是这个编码游戏的新手,但在这段代码中找不到我的语法/解析错误。错误是说第86行是代码的结尾。我曾试图添加括号,但运气不佳。这可能是一个基本的问题,但我已经为此挣扎了一段时间,所以我想我应该在这里把它拍下来,看看我是否能得到一些明确的指导,不再只是扔东西进去

    <html>
    <head>
<title>View Guestbook</title>
<link rel="stylesheet" type="text/css" href="css/king.css" />
  </head>

   <body>
  <img src="images/KingLogo.jpg"><br>

    <?php
include "king_common_functions.php";

viewGuestbook();

     //****************************************************************
     //Display Admin Guestbook Data (All Submissions)
    //****************************************************************

function viewGuestbook()
{
    $outputDisplay = "";
    $myrowcount = 0;

    $statement  = "SELECT lastname, firstname, contact_type, contact_info,";
    $statement  = "city, comments, date_added";
    $statement .= "FROM u1585_Guestbook ";
    $statement .= "ORDER BY lastname ";

    $sqlResults = selectResults($statement);

    $error_or_rows = $sqlResults[0];

    if (substr($error_or_rows, 0 , 5) == 'ERROR')
    {
        print "<br />Error on DB";
        print $error_or_rows;
    } else {
        $arraySize = $error_or_rows;

            for ($i=1; $i <= $error_or_rows; $i++)
            {
                $lastname = $sqlResults[$i]['lastname'];
                $firstname = $sqlResults[$i]['firstname'];
                $contact_type = $sqlResults[$i]['contact_type'];
                $contact_info = $sqlResults[$i]['contact_info'];
                $city = $sqlResults[$i]['city'];
                $comments = $sqlResults[$i]['comments'];
                $date_added = $sqlResults[$i]['date_added'];

                $outputDisplay  = "<h3>View Guestbook:</h3>";
                $outputDisplay .= '<table border=1 style="color: black;">';
                $outputDisplay .= '<tr><th>Last Name</th><th>First Name</th><th>Contact Type</th><th>Contact Info</th>';
                $outputDisplay .= '<th>City</th><th>Comments</th><th>Date Added</th></tr>';

                $numresults = mysql_num_rows($sqlResults);

                for ($j = 0; $j < $numresults; $j++)
                {
                    if (!($j % 2) == 0)
                    {
                        $outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
                    } else {
                        $outputDisplay .= "<tr style=\"background-color: white;\">";
                    }

                $myrowcount++;

                $outputDisplay .= "<td>".$lastname."</td>";
                $outputDisplay .= "<td>".$firstname."</td>";
                $outputDisplay .= "<td>".$contact_type."</td>";
                $outputDisplay .= "<td>".$contact_info."</td>";
                $outputDisplay .= "<td>".$city."</td>";
                $outputDisplay .= "<td>".$comments."</td>";
                $outputDisplay .= "<td>".$date_added."</td>";
                $outputDisplay .= "</tr>";
            }
    }
    $outputDisplay .= "</table>";
    $outputDisplay .= "<br /><br /><b>Number of Rows in Results: $myrowcount </b>    <br /><br />";
    print $outputDisplay;
    }
    ?>
    </p>

     </body>
    </html>

查看留言簿


您的函数缺少右括号。一个像样的IDE或文本编辑器会很快发现这一点。

您的函数缺少右括号。一个像样的IDE或文本编辑器会很快为您发现这一点。

您的
for
循环没有正确关闭,我认为:

for ($j = 0; $j < $numresults; $j++)
    {
    if (!($j % 2) == 0)
       {
       $outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
    } else {
       $outputDisplay .= "<tr style=\"background-color: white;\">";
    }

$myrowcount++;
for($j=0;$j<$numresults;$j++)
{
如果(!($j%2)==0)
{
$outputDisplay.=“”;
}否则{
$outputDisplay.=“”;
}
$myrowcount++;

缩进代码可以更容易地发现缺少大括号的地方。

此处的
for
循环没有正确关闭,我认为:

for ($j = 0; $j < $numresults; $j++)
    {
    if (!($j % 2) == 0)
       {
       $outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
    } else {
       $outputDisplay .= "<tr style=\"background-color: white;\">";
    }

$myrowcount++;
for($j=0;$j<$numresults;$j++)
{
如果(!($j%2)==0)
{
$outputDisplay.=“”;
}否则{
$outputDisplay.=“”;
}
$myrowcount++;

缩进代码可以更容易地发现缺少大括号的地方。

如果代码缩进正确,解决这些类型的问题会容易得多如果代码缩进正确,解决这些类型的问题会容易得多OI-这些是什么编码约定?伤了我的眼睛。;)我可能弄错了,但是s来形成
。看起来不错。但是正如你在混乱中所说的缩进。@MathieuImbert-我想你可能是对的。某处缺少一个大括号,我想它可能在
$outputDisplay
lines@Madbreaks-这叫做“从问题中剪切和粘贴”。显然,除了一个真正的风格:DOi-那些是什么编码约定?伤了我的眼睛。;)我可能弄错了,但是
foreach
迭代形成
。看起来不错。但是正如你所说的那样,缩进很混乱。@MathieuImbert-我想你可能是对的。某处缺少一个大括号,我想它可能在
$outputDis后面播放
lines@Madbreaks-这被称为“从问题中剪切和粘贴”。显然,除了一种真正的支撑风格外,没有其他支撑风格。:D