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 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计