Note that there are some explanatory texts on larger screens.

plurals
  1. POcreated a PDF that outputs weird characters
    primarykey
    data
    text
    <p>This is my code which will get data from the database then store it in a table for .pdf file:</p> <pre><code>&lt;?php // test the table functions error_reporting(E_ALL); include('includes/pdf/class.ezpdf.php'); //echo 'AAA-1-'; $pdf = new Cezpdf(); //$pdf-&gt;selectFont('./fonts/Helvetica'); //connect to db session_start(); require_once('connect/ticketivity_connect.php'); //echo 'AAA-2-'; //get customer details $sql_cust = "SELECT * FROM customers where customer_id = '".$_GET['customerid']."'"; $res_cust = mysql_query($sql_cust); $num_cust = mysql_num_rows($res_cust); $row_cust = mysql_fetch_assoc($res_cust); //display customer details $db_data[] = array('first' =&gt; 'Customer Name:', 'second' =&gt; $row_cust['cust_name']); $db_data[] = array('first' =&gt; 'Phone Number:', 'second' =&gt; $row_cust['cust_phone']); $db_data[] = array('first' =&gt; 'Address:', 'second' =&gt; $row_cust['cust_address']); $db_data[] = array('first' =&gt; '&gt;Customer Ref/ Room Number:', 'second' =&gt; $row_cust['cust_ref']); //echo 'AAA-3-'; //get order $sql_orderinfo= "SELECT * FROM orders where customer_id = '".$_GET['customerid']."'"; $res_orderinfo = mysql_query($sql_orderinfo); $num_orderid = mysql_num_rows($res_orderinfo); $row_orderid = mysql_fetch_assoc($res_orderinfo); //echo 'AAA-4-'; //display order id $orderid_len = strlen($row_orderid['order_id']); if($orderid_len == 1) { //echo 'AAA1--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; '00000'.$row_orderid['order_id']); } else if ($orderid_len == 2){ //echo 'AAA2--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; '0000'.$row_orderid['order_id']); } else if ($orderid_len == 3){ //echo 'AAA3--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; '000'.$row_orderid['order_id']); } else if ($orderid_len == 4){ //echo 'AAA4--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; '00'.$row_orderid['order_id']); } else if ($orderid_len == 5){ //echo 'AAA5--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; '0'.$row_orderid['order_id']); } else if ($orderid_len == 6){ //echo 'AAA6--'; $db_data[] = array('first' =&gt; 'Order ID:', 'second' =&gt; $row_orderid['order_id']); } //table columns $col_names = array( 'first' =&gt; 'first', 'second' =&gt; 'second', ); //echo 'AAA-5-'; $table_title = 'Customer Details'; //echo 'AAA-6-'; $pdf-&gt;ezTable($db_data, $col_names, $table_title, array('width'=&gt;550)); if (isset($d) &amp;&amp; $d){ //echo 'AAA-if'; $pdfcode = $pdf-&gt;output(1); $pdfcode = str_replace("\n","\n&lt;br&gt;", $pdfcode); echo '&lt;html&gt;&lt;body&gt;'; echo trim($pdfcode); echo '&lt;/body&gt;&lt;/html&gt;'; } else { //echo 'AAA-else'; $pdf-&gt;ezStream(); } ?&gt; </code></pre> <p>Output:</p> <pre><code>%PDF-1.3 %���� 1 0 obj &lt;&lt; /Type /Catalog /Outlines 2 0 R /Pages 3 0 R &gt;&gt; endobj 2 0 obj &lt;&lt; /Type /Outlines /Count 0 &gt;&gt; endobj 3 0 obj &lt;&lt; /Type /Pages /Kids [6 0 R ] /Count 1 /Resources &lt;&lt; /ProcSet 4 0 R &gt;&gt; /MediaBox [0.000 0.000 595.280 841.890] &gt;&gt; endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj &lt;&lt; /Creator (R and OS php pdf writer, http://www.ros.co.nz) /CreationDate (D:20100817) &gt;&gt; endobj 6 0 obj &lt;&lt; /Type /Page /Parent 3 0 R /Contents [ 7 0 R 8 0 R ] &gt;&gt; endobj 7 0 obj &lt;&lt; /Filter /FlateDecode /Length 120 &gt;&gt; stream x��2�300P@&amp;�ҹ�,�\����`di�gfb�`ah�gai�����`h�d�)(h8����)���$f�k*�d)��pb1h����8sK�qF�@����F@��m\����-� endstream endobj 8 0 obj &lt;&lt; /Filter /FlateDecode /Length 94 &gt;&gt; stream x��2�300P@&amp;�ܹʹ�,���L,��,, r`"�@$��Qi����Jct�03�|C4��(" �7����2D�a����T4z endstream endobj xref 0 9 0000000000 65535 f 0000000015 00000 n 0000000080 00000 n 0000000126 00000 n 0000000257 00000 n 0000000286 00000 n 0000000391 00000 n 0000000464 00000 n 0000000657 00000 n trailer &lt;&lt; /Size 9 /Root 1 0 R /Info 5 0 R &gt;&gt; startxref 823 %%EOF </code></pre> <p>What do I need to do/add?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload