解析错误:语法错误,意外']',期待T_STRING或T_VARIABLE或T_NUM_STRING

时间:2014-03-10 07:57:25

标签: php sendmail html-email

我正在尝试从数据库中检索数据并在文本邮件功能的表头中显示该数据,但我收到错误:

Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING

任何人都可以告诉我如何解决此错误

我的代码:

 $text_mail.= "<table style='margin:0px'>
    <tr>
    <th>Country</th>
    <th>Networkname </th>
    <th>Mcc</th>
    <th>Mnc</th> 
    <th>Oldprice </th>      
    <th>Newprice </th>      
    <th>Comments </th>  
     <?php  


      $dbHost = 'localhost'; // usually localhost
$dbUsername = 'xxxx';
$dbPassword = 'xxxxxxxxx';
$dbDatabase = 'xxxxxxxxxxxx';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");

    $ColumnNames = mysql_query('select clientid from client_list ORDER BY `clientid` ASC') or die('mysql error');       
    $columnArray=array();
    $i=0;       
    while($data3=mysql_fetch_array($ColumnNames))
    {
        $columnArray[]=$data3[0];

            echo '<th style='width:67px;' class='. $columnArray[$i] .' >" . $columnArray[$i] . " 
                </th>';

            echo'<th></th>';


    $i++;   
            }

    ?>  

    </tr>";

4 个答案:

答案 0 :(得分:0)

纠正这些:

$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die (\"Unable to connect to Database Server.\");
mysql_select_db ($dbDatabase, $db) or die (\"Could not select database.\");

或使用单引号

答案 1 :(得分:0)

如果这不是拼写错误,则需要在

之后添加结尾“(双引号)

更改

    $text_mail.= "<table style='margin:0px'>
    <tr>
    <th>Country</th>
    <th>Networkname </th>
    <th>Mcc</th>
    <th>Mnc</th> 
    <th>Oldprice </th>      
    <th>Newprice </th>      
    <th>Comments </th>

to 

$text_mail.= "<table style='margin:0px'>
<tr>
<th>Country</th>
<th>Networkname </th>
<th>Mcc</th>
<th>Mnc</th> 
<th>Oldprice </th>      
<th>Newprice </th>      
<th>Comments </th> "; 

答案 2 :(得分:0)

删除<?php标记,因为您已经在php

答案 3 :(得分:0)

  1. 如果这不是拼写错误,那么你需要添加结尾&#34; (双引号)
  2. 之后
  3. 结束后删除php标签。 改变

    $ text_mail。=&#34;          国家     网络名字     MCC     MNC     旧价格     新价格     评论

  4. $text_mail.= "<table style='margin:0px'>
    <tr>
    <th>Country</th>
    <th>Networkname </th>
    <th>Mcc</th>
    <th>Mnc</th> 
    <th>Oldprice </th>      
    <th>Newprice </th>      
    <th>Comments </th> ";