解析错误:语法错误,第29行意外T_STRING

时间:2013-12-24 06:12:06

标签: php html

我仍然是PHP的新手,我正在尝试将html合并到我的页面中,我不断得到以下错误,我似乎无法弄明白。

  

“解析错误:语法错误,第29行D:\ Hosting \ 11304243 \ html \ cnghldb \ cnghlplayerinfo.php中的意外T_STRING”第29行是代码中的第二行

while($row = mysql_fetch_array($oPlayerInfo))
{
Print "<body>";
Print "<div align="left">";
Print "<h2><strong>".$row['FirstName']." ".$row['LastName']."</strong></h2><br>";
Print "table width="710" border="0">;
Print "<tr>";
Print "<td width="188"<strong>Birthdate:</strong>" ".$row['DOB']."</td><br>";
Print "<td width="225"<strong>Nation:</strong></td>" ".$row['Nation']."</td><br>";
Print "<td width=" rowspan="8"><div align="center"><img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";
Print "</tr>";
Print "<tr>" ;
Print '<td><strong>"Position:</strong> ".$row['Position']. </td>"<br>';
Print '<td><strong>"CNGHL Team:</strong> ".$row['CNGHLRights']. </td>"<br>';
Print "</tr>";
Print "<tr>";
Print "<td><strong>Height:</strong> ".$row['Height']. </td>"<br>";  
Print "<td><strong>Weight:</strong> ".$row['Weight']. </td>"<br>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>NHL Team:</strong> ".$row['Team']. </td>"<br>";
Print "<td><&nbsp;</td>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>Draft Position:</strong> ".$row['CNDraftPOS'].</td>"<br>";
Print "<td><strong>Draft Year:</strong> ".$row['CNDraftYR'].</td>"<br>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM'].<td>"<br>";
Print "<td>&nbsp;</td>";
Print "</tr>";
Print "<tr>";
Print '<td height="88">&nbsp;</td>';
Print "<td>&nbsp;</td>";
Print "</tr>";
Print '<tr>';
Print '<td height="58">&nbsp;</td>';
Print "<td>&nbsp;</td>";
Print "</tr>";
Print "</table>";
Print "<p>&nbsp;</p>";
Print '<p><img src="http://www.cnghl.biz/cnghldb/pageimages/statistics.gif" width="190" height="18" /></p>';

8 个答案:

答案 0 :(得分:0)

将内部的双引号更改为单引号:

当前Print "<div align="left">"; 新的将是Print "<div align='left'>";

所有语法错误相同。

答案 1 :(得分:0)

您的双引号不在正确的位置。

请替换

Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM'].<td>"<br>";

通过

Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM']."<td><br>";

另外,请删除HTML标记内的双引号,如:

Print "<td width="188"<strong>Birthdate:</strong>" ".$row['DOB']."</td><br>";

应该是:

Print "<td width='188'<strong>Birthdate:</strong>" ".$row['DOB']."</td><br>";

答案 2 :(得分:0)

跟进Crackertastic的意思:

 Print "<div align="left">"

应该看起来像以下之一

 Print "<div align='left'>"
 Print "<div align=\"left\">"
 Print '<div align="left">'

答案 3 :(得分:0)

更改

Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM'].<td>"<br>";

Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM']."<td><br>";
第29行

* <td> should be inside quotes

答案 4 :(得分:0)

这是你的修复

Print "<div align=\"left\">";

答案 5 :(得分:0)

使用IDE。

Notepad ++选择了它

 Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM'].<td>"<br>";

引用错误的地方

因此出现错误消息

答案 6 :(得分:0)

您的代码中存在很多问题。您没有正确使用双引号和单引号。我在这里删除了错误:

while($row = mysql_fetch_array($oPlayerInfo))
{
Print "<body>";
Print "<div align='left'>";
Print "<h2><strong>".$row['FirstName']." ".$row['LastName']."</strong></h2><br>";
Print "table width='710' border='0'>";
Print "<tr>";
Print "<td width='188'<strong>Birthdate:</strong> ".$row['DOB']."</td><br>";
Print "<td width='225'<strong>Nation:</strong></td> ".$row['Nation']."</td><br>";
Print "<td width='' rowspan='8'><div align='center'><img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";
Print "</tr>";
Print "<tr>" ;
Print '<td><strong>Position:</strong> '.$row['Position']. '</td><br>';
Print '<td><strong>"CNGHL Team:</strong> '.$row['CNGHLRights']. '</td><br>';
Print "</tr>";
Print "<tr>";
Print "<td><strong>Height:</strong> ".$row['Height']. "</td><br>";  
Print "<td><strong>Weight:</strong> ".$row['Weight']. "</td><br>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>NHL Team:</strong> ".$row['Team']. "</td><br>";
Print "<td><&nbsp;</td>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>Draft Position:</strong> ".$row['CNDraftPOS']."</td><br>";
Print "<td><strong>Draft Year:</strong> ".$row['CNDraftYR']."</td><br>";
Print "</tr>";
Print "<tr>";
Print "<td><strong>Drafted By:</strong> ".$row['CNDraftTEAM']."<td><br>";
Print "<td>&nbsp;</td>";
Print "</tr>";
Print "<tr>";
Print '<td height="88">&nbsp;</td>';
Print "<td>&nbsp;</td>";
Print "</tr>";
Print '<tr>';
Print '<td height="58">&nbsp;</td>';
Print "<td>&nbsp;</td>";
Print "</tr>";
Print "</table>";
Print "<p>&nbsp;</p>";
Print '<p><img src="http://www.cnghl.biz/cnghldb/pageimages/statistics.gif" width="190" height="18" /></p>';
}

答案 7 :(得分:0)

请尝试此代码,您在print()

中使用过多次双引号
    while($row = mysql_fetch_array($oPlayerInfo))
    {

    Print '<body>';
    Print '<div align="left">';
    Print '<h2><strong>'.$row["FirstName"].' '.$row["LastName"].'</strong></h2><br>';
    Print '<table width="710" border="0">';
    Print '<tr>';
    Print '<td width="188"><strong>Birthdate:</strong>'.$row["DOB"].'</td><br>';
    Print '<td width="225"><strong>Nation:</strong></td>'.$row["Nation"].'</td><br>';
    Print '<td width="" rowspan="8"><div align="center"><img                 src="http://www.cnghl.biz/cnghldb/images/'.$iPlayerID.'.jpg">';
    Print '</tr>';
    Print '<tr>' ;
    Print '<td><strong>Position:</strong>'.$row["Position"].'</td><br>';
    Print '<td><strong>CNGHL Team:</strong> '.$row["CNGHLRights"].'</td><br>';
    Print '</tr>';
    Print '<tr>';
    Print '<td><strong>Height:</strong>'.$row["Height"].'</td><br>';  
    Print '<td><strong>Weight:</strong>'.$row["Weight"].'</td><br>';
    Print '</tr>';
    Print '<tr>';
    Print '<td><strong>NHL Team:</strong>'.$row["Team"].'</td><br>';
    Print '<td>&nbsp;</td>';
    Print '</tr>';
    Print '<tr>';
    Print '<td><strong>Draft Position:</strong>'.$row["CNDraftPOS"].'</td><br>';
    Print '<td><strong>Draft Year:</strong>'.$row["CNDraftYR"].'</td><br>';
    Print '</tr>';
    Print '<tr>';
    Print '<td><strong>Drafted By:</strong>'.$row["CNDraftTEAM"].'<td><br>';
    Print '<td>&nbsp;</td>';
    Print '</tr>';
    Print '<tr>';
    Print '<td height="88">&nbsp;</td>';
    Print '<td>&nbsp;</td>';
    Print '</tr>';
    Print '<tr>';
    Print '<td height="58">&nbsp;</td>';
    Print '<td>&nbsp;</td>';
    Print '</tr>';
    Print '</table>';
    Print '<p>&nbsp;</p>';
    Print '<p><img src="http://www.cnghl.biz/cnghldb/pageimages/statistics.gif"         width="190" height="18" /></p>';

    }