2014-03-12 100 views
-2

繼承人我的代碼,當我第一次嘗試從我的數據庫顯示所有數據使用我的查詢它出現,但是當我將此添加到我的查詢WHERE SECTION ='$ .thissection'「我有PDF錯誤,我已經設置了POST調用我的網頁上的價值就行得連工作,什麼是錯的我的代碼,請我真的需要它,從mysql生成報告,出現錯誤

include_once('dompdf\dompdf_config.inc.php'); 

    $html = '<!DOCTYPE html> 
    <html> 

    <head> 
    <meta charset="utf-8"> 

    </head> 
    <body> 
     <div id="container"> 
     <caption><h2 style="margin-left: 180px;">St. Therese Lisioux School of Cainta </h2></caption> 
      <table class="zebra"> 







    $thissubject = $_POST['subject']; 
    $thissection = $_POST['section']; 
    $thisgrade_level = $_POST['grade_level']; 

     $sqlQuery = mysql_query("SELECT si.STUDENT_ID, concat(si.LNAME,', ',si.FNAME) as Name, 
        sg.* 
        From student_info si Left join grades sg On si.STUDENT_ID = sg.STUDENT_NO 
        WHERE SECTION = '$.thissection'"); 
     while($row = mysql_fetch_assoc($sqlQuery)) 
     { 

     $student_id = $row['STUDENT_NO']; 
     $Name = $row['Name']; 
     $SUBJECT_NAME = $row['SUBJECT']; 
     $first_Grading = $row['FIRST_GRADING']; 
     $second_Grading = $row['SECOND_GRADING']; 
     $third_Grading = $row['THIRD_GRADING']; 
     $fourth_Grading =$row['FOURTH_GRADING']; 
     $final = $row['FINAL']; 
     $status = $row['STATUS']; 


     $html .= '<tbody> 
     <tr class="warning"> 
      <td>'.$student_id.'</td> 
      <td>'.$Name.'</td> 
      <td>'.$SUBJECT_NAME.'</td> 
      <td>'.$first_Grading.'</td> 
      <td>'.$second_Grading.'</td> 
      <td>'.$third_Grading.'</td> 
      <td>'.$fourth_Grading.'</td> 
      <td>'.$final.'</td> 
      <td>'.$status.'</td> 

     </tr> 
     </tbody>'; 



     } 

    $html .= ' </table> 
     </div> 
    </body> 
    </html> 

    '; 

    $dompdf = new DOMPDF(); 
    $dompdf ->set_paper("a4", "landscape"); 
    $dompdf ->load_html($html); 
    $dompdf ->render(); 
    $dompdf ->stream('Student_report.pdf'); 

    ?>strong text 
+1

嚴重的PHP語法錯誤! 'include_once()'中使用斜槓而不是反斜槓,並且在變量中使用PHP代碼? – Raptor

+0

請正確格式化您的代碼! – plaes

回答

1

你的代碼有嚴重的PHP語法錯誤。

  1. 您使用單引號的字符串變量,它不會被PHP解析器解析PHP內部代碼。
  2. 此外,你沒有逃脫的代碼。
  3. 使用斜線,而不是反斜線在include_once()
  4. 使用過時mysql_*功能和代碼受到SQL注入攻擊你沒有初始化你的MySQL連接
  5. 停止,因爲你直接允許被插入POST值的查詢。改爲使用MySQLiPDO。對於PDO,這是一個很好的tutorial
  6. 您的HTML缺少<title>
  7. 您的錯誤處理機制在哪裏?你預計各種投入都沒有錯誤?

對於快速修復,更改行:

<table class="zebra"> 

​​

爲了結束$html變量。