$report_pdf = stripslashes($pdf_data);
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);
$pdf->MultiCell(190, 5, $report_pdf);
$pdfcontent = $pdf->Output("", "S");
$currentDate =date('y-m-d');
$endDate = date('y-m-d', strtotime("+36 months"));
$conn = mysqli_connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT);
// Check connection
if (! $conn) {
die("Connection failed: " . mysqli_connect_error());
}
$id = $_SESSION['userid'];
$iban = $_SESSION['iban'];
$bic = $_SESSION['bic'];
$sql = "INSERT INTO ".table." (userid, useriban, userbic,pdf, start, end )
VALUES ($id, '$iban', '$bic', ?,'$currentDate', '$endDate')";
if ($query = $conn->prepare($sql))
{
$query->bind_param('s', $pdfcontent);
$query->execute();
}
// To Retrieve PDF from DataBase
$sql=$conn->prepare("SELECT pdf FROM sauberlux_com.tbl_b2csepa where id = 1");
if( $query = $conn->prepare($sql))
{
$query->execute();
$query->store_result();
$query->bind_result($pdfcontent);
while($query->fetch())
{
header("Content-Length: " . strlen($pdfcontent) );
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename=test.pdf');
header("Content-Transfer-Encoding: binary
");
echo $pdfcontent;
}
}
my code is working correctly to store pdf data as blob in database. but when i want to retrieve that data data from database that part of my code is not working. please any one help me. I have checked my query its selecting the correct data but i am not getting any output or anything.