dqls67891 2012-08-21 20:44
浏览 10
已采纳

解析错误......根本找不到它? (第86行)

I'm new to this coding game, but I cannot find my syntax/parse error in this code. The error is saying Line 86 which is the end of the code. I have tried to add brackets, but have not had luck. This is likely a basic question, but I have been struggling with it for awhile so thought I'd shoot it up here to see if I could get some clear guidance and stop just throwing stuff in.

    <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>
  • 写回答

2条回答 默认 最新

  • donglun2010 2012-08-21 20:47
    关注

    Your for loop here isn't being closed properly, I think:

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

    Indenting your code makes it much easier to spot where you're missing braces.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值