Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:03:50+00:00 2026-06-18T06:03:50+00:00

I’m experiencing a very strange problem with my PHP script hanging even after the

  • 0

I’m experiencing a very strange problem with my PHP script “hanging” even after the background processes have finished running. I am running PHP 5.3, Windows Server 2008 R2, IIS7 with Tomcat Apache installed.

Project Background My script generates PDF forms through the “shell_exec()” function. Anywhere between 1 – 3,000 forms can be generated. Once all forms have been generated, a download link and “start over” link are supposed to show at the bottom of the page — instead, the site continues to “load” and the links never show up — even when I check the server and see that all files have finished generating.

This issue only comes up when generating 300+ forms, which takes 3-6mins.

I have set my php.ini’s “max_execution_time” to 1200 (20mins), and IIS7’s “Connection Timeout” is also set to 1200 seconds. Here are links to pictures of these settings to confirm I have them set properly:
http://i49.tinypic.com/15gavew.png — php.ini
http://i49.tinypic.com/9u5j0n.png — IIS7

Is there another setting that I am missing? Is there a Tomcat Apache Connection Timeout setting that I am unaware of? Does PHP have another “timeout” setting besides “max_execution_time” and “set_time_out”? I’ve exhausted my resources and have not a clue as to why my script continues to hang, even after the “while loop” has finished running and all PDFs have been successfully created.

Thank you for any and all help/advice.

While Loop Code

/* build zip & directory for PDFs */
$zip = new ZipArchive;
$time = microtime(true);

    $new_dir = "c:/pdfgenerator/f-$time";
    if(!file_exists($new_dir)) {
      mkdir($new_dir);
    }


$res = $zip->open("pdf/tmppdf/mf-pdfs_" . $time . ".zip", ZipArchive::CREATE);


$num = 0;
while($row = mysql_fetch_array($result)) {

    /* associate a random # assigned to each PDF file name */
    $num++;
        include($form);
    $rand = rand(1,50000);
     $file_num = $num * $rand;

    $fo = fopen('c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.html', 'w') or die("can't open file");

    fwrite($fo, $output);
    echo shell_exec('c:\wkhtmltopdf\wkhtmltoimage c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.html c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg');

    /* the follow uses ghost script to execute the ImageMagick convert command from cmd.exe */
    $magick_dir = 'C:\imagemagick'; // install IM in short DOS 8.3 compatible path
    $send_cmd=$magick_dir .'\convert c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg -resize "1710x2200^!" c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg' ;

    echo shell_exec($send_cmd);
    $send_cmd=$magick_dir .'\convert c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.pdf';
    echo shell_exec($send_cmd);

    /* EO ghostscript code */

/* add the newly generated files to the Zip Archive */
    if ($res === TRUE) {
    //echo "RESULT TRUE...";
     $zip->addFile('c:/pdfgenerator/f-' . $time . '/mf_pdf-' . $time . '-' . $file_num . '.pdf','c:/pdfgenerator/f-' . $time . '/mf_pdf-' . $time . '-' . $file_num . '.pdf');

    //echo "FILE ADDED!";
    } 

}
echo "<h2><a href=\"http://50.63.85.232/med/pdf/tmppdf/mf-pdfs_$time.zip\">Download Zip</a></h2>";
echo "<h2><a href=\"index.php\">Start Over</a></h2>";
$zip->close("pdf/tmppdf/mf-pdfs_" . $time . ".zip", ZipArchive::close());
}

}

Specific Shell Lines

echo shell_exec('c:\wkhtmltopdf\wkhtmltoimage c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.html c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg');

    /* the follow uses ghost script to execute the ImageMagick convert command from cmd.exe */
    $magick_dir = 'C:\imagemagick'; // install IM in short DOS 8.3 compatible path
    $send_cmd=$magick_dir .'\convert c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg -resize "1710x2200^!" c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg' ;

    echo shell_exec($send_cmd);
    $send_cmd=$magick_dir .'\convert c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.jpeg c:\\pdfgenerator\\f-' . $time . '\\mf_pdf-' . $time . '-' . $file_num . '.pdf';
    echo shell_exec($send_cmd);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:03:52+00:00Added an answer on June 18, 2026 at 6:03 am

    converted all of my mysql_ functions, which are now deprecaded as of PHP 5.5, and utilized MySQLi functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
I have been unable to fix a problem with Java Unicode and encoding. The
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.