File download not working in php -


but same error below code well… can please share me suggestions..

error:

warning: cannot modify header information - headers sent (output started @ /home/stthohuu/public_html/sp/announcements.php:1) in /home/stthohuu/public_html/sp/announcements.php on line 45

warning: cannot modify header information - headers sent (output started @ /home/stthohuu/public_html/sp/announcements.php:1) in /home/stthohuu/public_html/sp/announcements.php on line 46

<?php if(isset($_get['id']))  { ob_start(); // if id set file id database $con = mysql_connect('localhost', abc’, 'abc') or die(mysql_error()); $db = @mysql_select_db('stthohuu_church', $con); $id    = $_get['id']; $query = "select name, type, size, content " .          "from newsletter id = '$id'"; $result = mysql_query($query) or die('error, query failed'); list($name, $type, $size, $content) = mysql_fetch_array($result); header("content-length: $size"); header("content-type: $type"); header("content-disposition: attachment; filename=$name"); ob_clean(); echo $content; mysql_close();  exit; } ?> </head> <body>      <?php         //database connection         $con = mysql_connect('localhost', abc', 'abc') or die(mysql_error());         //select database         $db = mysql_select_db('stthohuu_church', $con);         $query = "select id, name newsletter order id desc";         $result = mysql_query($query) or die('error, query failed');         if(mysql_num_rows($result) == 0)         {         echo "no files found in db<br>";         }          else         {         while(list($id, $name) = mysql_fetch_array($result))         {         ?>         <a href="../archive_newsletter.php?id=<?php echo urlencode($id);?>"         ><?php echo urlencode($name);?></a> <br>         <?php          }         }         mysql_close();     ?> </body> </html> 


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -