【问题标题】:Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING解析错误:语法错误,意外的 ']',需要 T_STRING 或 T_VARIABLE 或 T_NUM_STRING
【发布时间】:2014-03-10 07:57:25
【问题描述】:

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

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>";

【问题讨论】:

  • 希望在发布代码时出现错误但您忘记关闭评论";
  • 语法高亮说明。

标签: php sendmail html-email


【解决方案1】:

纠正这些:

$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.\");

或使用单引号

【讨论】:

    【解决方案2】:

    如果这不是拼写错误,那么您需要在

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

    改变

        $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> "; 
    

    【讨论】:

      【解决方案3】:

      删除&lt;?php标签,因为你已经在php中了

      【讨论】:

        【解决方案4】:
        1. 如果这不是拼写错误,那么您需要在
        2. 之后添加结尾 "(双引号)
        3. 结束后去掉php标签。 改变

          $text_mail.= " 国家 网络名字 中控中心 跨国公司 旧价格
          新价格
          评论

        $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> "; 
        

        【讨论】:

          猜你喜欢
          • 2011-11-07
          • 2012-01-14
          • 1970-01-01
          • 2014-07-03
          • 1970-01-01
          • 2012-03-23
          • 2017-04-08
          • 1970-01-01
          相关资源
          最近更新 更多