Jump to content

show pdf - newbie


sturobinson81

Recommended Posts

Hi,

 

newbie programmer here.

 

Trying to get the following code working, but i keep getting an error.

Probably something stupid, or maybe just my lack of knowledge :)

can post error message if it would help. Any help very much appreciated :)

 

 

<?php
include 'connect.php';
$result = mysqli_query($con,"SELECT * FROM pdfs
WHERE Keywords LIKE '%stu%'");
 
 
while($row = mysqli_fetch_array($result))
  {
  $pdf=$row['FILENAME'];
  echo $row['Keywords'];
  echo "<br>";
  echo $row['FILENAME'];
  echo "<br>";
  
  header("Content-type: application/pdf");
  header("Content-Disposition: inline; filename=$pdf");
  readfile($pdf);
  
  }
 
mysqli_close($con);
?> 
 
 
 
 
 
 
 

 

Link to comment
Share on other sites

Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:13) in /home/bictech/public_html/newsite/search2.php on line 15


 


Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:13) in /home/bictech/public_html/newsite/search2.php on line 16


stu test2


newsite/pdfs/test2.pdf


 


Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:13) in /home/bictech/public_html/newsite/search2.php on line 15


 


Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:13) in /home/bictech/public_html/newsite/search2.php on line 16

Link to comment
Share on other sites

I still get the following errors...

 

Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:12) in /home/bictech/public_html/newsite/search2.php on line 8

Warning: Cannot modify header information - headers already sent by (output started at /home/bictech/public_html/newsite/connect.php:12) in /home/bictech/public_html/newsite/search2.php on line 9

%PDF-1.3 %âãÏÓ 4 0 obj << /Type /Page /Parent 2 0 R /Contents 10 0 R /MediaBox [0.0000 0.0000 1190.5512 841.8898] /TrimBox [0.0000 0.0000 1190.5512 841.8898] /CropBox [0.0000 0.0000 1190.5512 841.8898] /Resources << /ProcSet [/PDF /ImageC /Text /ImageB] /XObject << /Im12 12 0 R /Im49 49 0 R /Im50 50 0 R /Im70 70 0 R /Im71 71 0 R >> /Font << /F13 13 0 R /F17 17 0 R /F21 21 0 R /F25 25 0 R /F30 30 0 R /F34 34 0 R /F38 38 0 R /Symb 43 0 R /F51 51 0 R /F55 55 0 R /F60 60 0 R /F65 65 0 R /F72 72 0 R >> /ExtGState << /GS11 11 0 R >> /ColorSpace << /CS48 48 0 R >> >> >> endobj 10 0 obj << /Filter [/FlateDecode ] /Length 4415 >> stream xÚÕ[É’7z¾3‚ݢØ9Ø^lRÉ´G#zØÖÅò!»*»+GU•ÅZšn=ˆŸÃ‡ŸÀbŸýþ²è¬^bd˜¡(d&ðã_¿)VQÿ‡Ðâ¿,ûÿôŸÙêù³ßýð1r½{þìãógšºJSFå Œ•LrrÎd%8wá/Bª°Í»ãäm÷üÙ?Ž÷ÄçÚQòëógþS.ðŽUÑœ`

 

and a lot more garbage...

 

anything im doing obviously wrong?

Link to comment
Share on other sites

my current code

------------------------------------------------

 

------------------------connect.php--------------------------

<?php
// Create connection
$con=mysqli_connect("bictechnology.co.uk","bictech_stu","bictech2014","bictech_pdfdb");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL:" . mysqli_connect_error();
  exit();
  }
?>

---------------------------------------------------

 

 

---------------------search2.php----------------------

<?php
include 'connect.php';
$result = mysqli_query($con,"SELECT * FROM pdfs
WHERE Keywords LIKE '%stu%'");
while($row = mysqli_fetch_array($result))
  {
 $pdf=$row['FILENAME']; 
  header("Content-type: application/pdf");
  header("Content-Disposition: inline; filename=$pdf");
  readfile($pdf);
  }
mysqli_close($con);
?>
--------------------------------------------------------------------------

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.