0

I am currently trying to create a pdf doc with ~230 pages.

PHP Version: 7.0.33 mpdf Version: 8.0.8

1 page looks like the page in this fiddle (different data only): https://jsfiddle.net/hw90L2kd/ this is my php code:

    setlocale(LC_TIME, "de_DE");

    require_once "../../vendor/autoload.php";
    require_once("../../020classes/Arrays.php");
    require_once("../../020classes/c_DB.php");
    $sql = "SELECT Verr_Rechnungen.*,pat.ZArt,pat.E_Nachrichten,adr.*
    FROM Verr_Rechnungen 
    LEFT JOIN pat ON (Verr_Rechnungen.AdrNr=pat.AdrNrPat)
    LEFT JOIN adr ON (Verr_Rechnungen.AdrNr=adr.AdrNr)
    WHERE  Rechnungsnummer >=".$_GET["rechnungsnummerstart"]." AND Rechnungsnummer <=".$_GET["rechnungsnummerende"]." 
    ORDER BY adr.FName,adr.VName,Land";

    $rs = $db->prepare($sql);
    $rs->execute(); //Im getting results from this

    $mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/temp']);
    
    while($row = $rs->fetch())
    {
        ob_start();
        $mpdf->AddPage();

        //here goes html page, which is generated with some php code

        $stylesheet = file_get_contents('rechnungRGDruck.css'); //same css as in the fiddle
        $mpdf->WriteHTML($stylesheet,1);
        $html = ob_get_contents();
        //send the captured HTML from the output buffer to the mPDF class for processing
        $mpdf->WriteHTML($html,2);
        ob_clean();
     }

$mpdf->Output("rechnungen.pdf","D");

I have around 230 customers for which i each create a page inside this pdf but i always get a 500 - Internal Server Error when trying to create ALL the pages at once. If i limit my Query to, lets say 150, its no problem. I´ve already unlimited the php execution time and increased the memory size to 512M, to try if thats the reason for the problem - without succeding. And even if i use

error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "php-error.log");

at the top of the file i am not able to generate ANY error at all, no log, nothing. Only a 500 - Internal Server error. due to the information on this post php return 500 error but no error log i searched all the files of mpdf for the @ symbol, and replaced it with nothing (just to try out if i get any error after), but nothing again.

I´ve tried upgrading PHP to 7.3, but it didnt work aswell.

Does someone know why this happens?

Loggi
  • 35
  • 1
  • 7
  • Have you enabled error logging in the PHP config? – ADyson Jan 05 '21 at 14:20
  • 1
    Since it's a 500 error. Have you checked the we server log for errors? Add this to the top of your script to enable errors in the script. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); – Jason K Jan 05 '21 at 14:23
  • 1
    **Warning**:You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized prepared statements instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even by trusted users, [you are still in risk of corrupting your data](https://bobby-tables.com/). [Escaping is not enough](https://stackoverflow.com/q/5741187). – Jason K Jan 05 '21 at 14:25
  • Where is the log file being written? Can the web server create it or even write to it? – Jason K Jan 05 '21 at 14:34
  • @ADyson yes, i have enabled logging. Please check the second box of code in the thread above. – Loggi Jan 05 '21 at 14:43
  • @JasonK I already enabled logging and put the log file where in a directory where it can be written, i enabled startup errors but still i didn´t get any error message or error inside the log. – Loggi Jan 05 '21 at 14:45
  • Have you checked the web server log? If your running apache under linux it would be at /var/log/apache2/error.log it will contain any errors that would prevent php from running. – Jason K Jan 05 '21 at 15:13
  • Unfortunately my hoster doesn´t use apache and therefore there is no var/log/apache2 directory. – Loggi Jan 05 '21 at 16:02
  • Well there must be an equivalent log. What webserver do they use? – ADyson Jan 05 '21 at 16:07
  • @ADyson Thats a good question, i will need to ask the host. – Loggi Jan 05 '21 at 19:46
  • @ADyson due to security reasons my host cannot give me this information, which means that i need to find another way to do the work. Thank you very much for your help and have a nice day! – Loggi Jan 07 '21 at 06:40
  • IMO that's ridiculous. If you're hosting something on their server then you have a legitimate need to know what technology you're running it on. I would be looking to find a more accommodating hosting company, personally. – ADyson Jan 07 '21 at 09:24

0 Answers0