$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\n");
echo $pdfcontent;
}
}
我的代码正常工作,将pdf数据存储为数据库中的blob。但是当我想从数据库中检索那些部分代码不起作用的数据时。请任何人帮助我。 我已经检查了我的查询,它选择了正确的数据,但我没有得到任何输出或任何东西。