解析错误意外的回声 - 即使没有丢失的半冒号。

时间:2017-06-10 10:45:31

标签: php html

解析错误:语法错误,意外'回声' (T_ECHO)在第48行的C:\ xampp \ htdocs \ Infobhan \ backend \ project_script.php中。似乎错误是第一个回声线。当删除给定的行时,它会显示mext echo line的错误。

   <?php 
      require 'connect.php';

$sql ='SELECT * FROM `job`';
$result= mysqli_query($link, $sql);

if($result){
     if(mysqli_num_rows($result)>0){
        while($row= mysqli_fetch_array($result)){
         $j_id=$row['id'];
         $sql2="SELECT * FROM issue i INNER JOIN job j ON i.job_id=j.id WHERE i.job_id='$j_id'";
         $result2= mysqli_query($link, $sql2);

        echo "<tr class='cell' data-toggle='modal' data-target='#j_".$row['id'].">
        <td>".$row['id']."</td>
        <td>".$row["customer"]."</td> 
        <td>".$row["type"]."</td>
        <td>".$row["job_desc"]."</td>
        <td>".$row["date"]."</td>
        <td>".$row["start_date"]."</td>
        <td>".$row["end_date"]."</td>
        <td>".$row["value"]."</td>
        <td>".$row["cost_exp"]."</td>
        <td>".$row["profit_prj"]."</td>
        <td>".$row["doc_ref"]."</td>              
        </tr> 
        ";

        echo "<div id='j_".$row['id']."' class='modal fade' role='dialog'>

           while($row2=mysqli_fetch_array($result2)){              
            $itemid=$row2[2];              
            $sql3= "SELECT * FROM issue i INNER JOIN stock s ON i.item_id=s.item_no WHERE s.item_no='$itemid'";              
            $result3= mysqli_query($link, $sql3);
            $row3= mysqli_fetch_array($result3);
                
             echo "<div class='row'> //error line 48
             <div class='col-lg-offset-1 col-lg-4'>";

             echo $row3[6];

             echo "</div>                       
             <div class='col-lg-offset-2 col-md-offset-2 col-sm-offset-2 col-xs-offset-2 col-lg-4 col-md-4 col-sm-4 col-xs-4'>";

             echo $row3[9];

             echo "</div>           
             </div>"; 

           }echo "</div>                                  
         }
     }
        else{
         echo"<tr> No Result </tr>";
     }
 }
else{
     die( "<tr>".mysqli_error($link)."</tr>" );
 }?>

2 个答案:

答案 0 :(得分:0)

您的代码似乎应该是

echo "<div class='row'><div class='col-lg-offset-1 col-lg-4'>";

而不是

echo "<div class='row'>
             <div class='col-lg-offset-1 col-lg-4'>";

因为php中的echo没有因新行

而得到任何封闭的引号

答案 1 :(得分:0)

删除echo之前的所有空格(发生错误的地方),直到之前的分号为止。如果您从其他地方复制粘贴代码,通常会出现此问题。这也复制了一些意想不到的不可打印的字符

 while($row2=mysqli_fetch_array($result2)){
            $item_id=$row2[2];
            $sql3= "SELECT * FROM issue i INNER JOIN stock s ON i.item_id=s.item_no WHERE s.item_no='$item_id'";
            $result3= mysqli_query($link, $sql3);
            $row3= mysqli_fetch_array($result3);
            echo "<div class='row'>
             <div class='col-lg-offset-1 col-lg-4'>";
             echo $row3[6];
             echo "</div>                       
             <div class='col-lg-offset-2 col-lg-4'>";
             echo $row3[9];
             echo "</div>           
             </div>"; 

           }