解析错误:语法错误,意外'<'在第44行的C:\ xampp \ htdocs \ jmb_system \ anggerik \ viewresident.php中

时间:2015-01-08 04:18:28

标签: php pdo parse-error

我在这个关于视图数据脚本的脚本上出现了这个错误。

请帮忙!我缺少“这是下面代码的最后三行。

function ListUnit()
{
    ?>  
    <table class="hilite" id="highlight"><thead>
        <tr><th>No.</th><th>Owner</th><th>Unit</th><th>Block</th><th>Floor</th><th>Number</th><th>Balance</th><th>Additional Info</th><th>Action</th></tr>
        </thead>
        <tbody>
        <?php
        $SQL="SELECT * FROM unit ORDER BY block, floor, unit ASC";
        $result=mysql_query($SQL);
        $i=1;
        while ($row=mysql_fetch_assoc($result))
        {
            $id=$row['id'];
            $ownerName=$row['ownerName'];
            $ownerHP=$row['ownerHP'];

            $name=$row['unitname'];
            $block=$row['block'];           
            $floor=$row['floor'];
            $unitnum=$row['unit'];          
            $sqft=$row['sqft'];
            $resitsyabas=$row['resit_syabas'];
            $ltsb=$row['LTSB'];
            $ppaa=$row['PPAA'];
            $b482=$row['b482'];
            $tbs=$row['TBS'];

            $addinfo=$row['addinfo'];
            $addinfo = wordwrap($addinfo, 30, "<br>", true);
            echo "<tr align=\"center\" valign=\"top\">";
            echo "<td>$i</td><td align=\"left\" valign=\"top\">Name:$ownerName<br>Contact:$ownerHP</td><td>$name</td><td>$block</td><td>$floor</td><td>$unitnum</td>
            <td align=\"left\">LTSB:RM$ltsb<br>PPAA:RM$ppaa<br>482:RM$b482<br>TBS:$tbs</td>
            <td align=\"left\">Area:$sqft sqft<br>Meter Syabas:$resitsyabas<br>$addinfo</td><td><a href=\"admin_unit.php?a=1&i=$id\">Edit</a></td>";
            echo "</tr>";
            $i++;
        }

    </tbody></table>
}
?>

所以,请咨询。我该如何以及在哪里修理它?

2 个答案:

答案 0 :(得分:0)

尝试在打印时用双倍替换单引号,如下所示:

echo "<td>$i</td><td align='left' valign='top'>Name:$ownerName<br>Contact:$ownerHP</td><td>$name</td><td>$block</td><td>$floor</td><td>$unitnum</td>
            <td align='left'>LTSB:RM$ltsb<br>PPAA:RM$ppaa<br>482:RM$b482<br>TBS:$tbs</td>
            <td align='left'>Area:$sqft sqft<br>Meter Syabas:$resitsyabas<br>$addinfo</td><td><a href='admin_unit.php?a=1&i=$id'>Edit</a></td>";

还有一点,你之前缺少回声:

$html .= "</tbody></table>";

答案 1 :(得分:0)

您无法在函数中使用HTML标记。

你必须使用

function ListUnit()
{
    $html = '<table class="hilite" id="highlight"><thead>';
        $html .= '<tr><th>No.</th><th>Owner</th><th>Unit</th><th>Block</th><th>Floor</th><th>Number</th><th>Balance</th><th>Additional Info</th><th>Action</th></tr>';
        $html .= '</thead>';
        $html .= '<tbody>';

        $SQL="SELECT * FROM unit ORDER BY block, floor, unit ASC";
        $result=mysql_query($SQL);
        $i=1;
        while ($row=mysql_fetch_assoc($result))
        {
            $id=$row['id'];
            $ownerName=$row['ownerName'];
            $ownerHP=$row['ownerHP'];

            $name=$row['unitname'];
            $block=$row['block'];           
            $floor=$row['floor'];
            $unitnum=$row['unit'];          
            $sqft=$row['sqft'];
            $resitsyabas=$row['resit_syabas'];
            $ltsb=$row['LTSB'];
            $ppaa=$row['PPAA'];
            $b482=$row['b482'];
            $tbs=$row['TBS'];

            $addinfo=$row['addinfo'];
            $addinfo = wordwrap($addinfo, 30, "<br>", true);
            $html .= "<tr align=\"center\" valign=\"top\">";
            $html .= "<td>$i</td><td align=\"left\" valign=\"top\">Name:$ownerName<br>Contact:$ownerHP</td><td>$name</td><td>$block</td><td>$floor</td><td>$unitnum</td><td align=\"left\">LTSB:RM$ltsb<br>PPAA:RM$ppaa<br>482:RM$b482<br>TBS:$tbs</td><td align=\"left\">Area:$sqft sqft<br>Meter Syabas:$resitsyabas<br>$addinfo</td><td><a href=\"admin_unit.php?a=1&i=$id\">Edit</a></td>";
            $html .= "</tr>";
            $i++;
        }

    $html .= "</tbody></table>";

    echo $html;
}
?>