I have an invoicing system with php and when I go to print a pdf invoice with Dompdf on my local network (before uploading the page) it works fine but when I upload the page to this server and I click my print button it does not generate me the pdf instead the page falls and shows me this error
guayogas.epizy.com can’t currently handle this request.
HTTP ERROR 500
I repeat, locally it works well for me. when I give my button that is responsible for calling the file that generates the pdf … it works perfectly, I am using Dompdf and I have also used FPDF to check if the problem was the library but it is not. the page falls on the server
An HTTP 500 error occurs when your PHP code is not working. You may want to look through your code and make sure it is correct.
When trying to access your website, you may see a page which returns the status code “500”. In Google Chrome, you’ll see a page with the error code HTTP ERROR 500.
There are typically two reasons which can cause this error:
The PHP code has crashed.
The .htaccess file contains invalid rules.
Here are some things you can try to debug and fix this.
Fixing crashing PHP code
A HTTP ERROR 500 simply tells you that the PHP code has crashed, but gives no information as to why it has crashed.
Gett…
3 Likes
but it works for me locally, is that normal?
<?php
include("db.php");
if (isset($_GET["id"])) {
$id = $_GET["id"];
$query = "SELECT * FROM gas WHERE ID = $id";
$resultado = mysqli_query($conn, $query);
if (mysqli_num_rows($resultado) == 1) {
$row = mysqli_fetch_array($resultado);
$nombre = $row["nombre"];
$galones = $row["galones"];
$precio = $row["precio"];
$fecha = $row["fecha"];
if ($galones == 6) {
$tanque = "Tanque de 25 lbs";
} else if ($galones == 12) {
$tanque = "Tanque de 50 lbs";
} else {
$tanque = "Cilindro de gas";
}
}
}
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new DOMPDF();
$dompdf->setPaper('b7', 'portrait');
ob_start();
include "factura.php";
$html = ob_get_clean();
$dompdf->loadHtml($html);
$dompdf->render(); //este comando renderiza el PDF
$dompdf->stream('FicheroEjemplo.pdf');
the problem occurs when I create a Dompdf instance
PDFs have been banned on free hosting because people were doing bad things with them. This could be a cause.
3 Likes
is there anything i can do to generate an invoice?
If the user only needs to see it and not select text, you may want to generate a PNG image.
https://www.php.net/manual/en/function.imagepng.php
The computer can print characters and designs.
https://www.sciencedirect.com/topics/engineering/thermal-printer
1 Like
I need to print as if it were an invoice on a thermal printer … could you print an image on a thermal businesswoman?
I think it is possible. As long as you don’t have an ancient thermal printer and you drivers are up to date, you should be fine.
2 Likes
ok, I’m going to find a way to print an image on a thermal printer, obviously without generating a pdf
system
Closed
December 2, 2021, 4:08pm
13
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.