radiations3 Posted August 6, 2011 Share Posted August 6, 2011 Q1: AS we know we can download easily the PDF file from the links like yoursite.com/help.pdf just like this can we also download the file which is saved in BLOB field if so then is the folllowing code right for that: <?php mysql_select_db("bakery") or die(mysql_error()); $id=$_GET['id']; // gets the id of the blobfield where the file is saved in database $file = mysql_query("SELECT file FROM pic WHERE `Desc`='".$id."'") or die(mysql_error()); $file = mysql_fetch_assoc ($image); $file = $image ['file']; header("content-type: application/pdf"); echo $file; ?> Q2: The above mentioned code is checked with the image and worked correctly I want to know can i use multiple headers in the same file (.php file) to get files of two different data types like if ($filetype == jpg) { header("content-type: image/pdf"); echo $file; } if ($filetype == pdf) { header("content-type: application/pdf"); echo $file; } Q3: Is the following code right for redirecting our page to any specified URL?? if ($help==true) { header("location: help/index.php"); } Link to comment https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/ Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 A1: Yes A2: Yes A3: Yes & No. The location header expects a complete url (domain and all). While it will usually work without it, it's always best to use it. Link to comment https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/#findComment-1253020 Share on other sites More sharing options...
radiations3 Posted August 6, 2011 Author Share Posted August 6, 2011 A1: Yes A2: Yes A3: Yes & No. The location header expects a complete url (domain and all). While it will usually work without it, it's always best to use it. you meant i must write if ($help==true) { header("location: http://yoursite.com/help/index.php"); } ???? Link to comment https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/#findComment-1253029 Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 Yeah, but on another note: if ($help) { header("location: http://yoursite.com/help/index.php"); } will do. Link to comment https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/#findComment-1253039 Share on other sites More sharing options...
radiations3 Posted August 6, 2011 Author Share Posted August 6, 2011 THANX!!! Link to comment https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/#findComment-1253041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.