Jump to content

Some questions needed to be answered ?


radiations3

Recommended Posts

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");

}

 

:confused:

Link to comment
https://forums.phpfreaks.com/topic/244000-some-questions-needed-to-be-answered/
Share on other sites

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");

}

 

????

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.