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 7188503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:05:56+00:00 2026-05-28T19:05:56+00:00

Our apache error_log was recently filled up with lines similar to the following (about

  • 0

Our apache error_log was recently filled up with lines similar to the following (about 50GB):

[Wed Feb 01 16:50:15 2012] [error] [client 123.123.123.123] PHP Warning:
unpack() [<a href='function.unpack'>function.unpack</a>]:  
 Type V: not enough input,  need 4, have 1
    in /var/www/vhosts/domain.com/httpdocs/imagecreatefrombmp.php on line 52

Line 52 in imagecreatefrombmp.bmp is as follows:

$COLOR = unpack("V",substr($IMG,$P,3).$VIDE);

This line is buried in a while loop.

If this issue happens again I want the code to quietly exit the while loop.

The problem is I cannot replicate the problem myself so I sort of need to solve it blind.

I’ve devised the following little solution. Would it serve the purpose? If the “Type V not input…” error occurs again would the try catch block catch it and return false?

    try{
        $COLOR = unpack("V",substr($IMG,$P,3).$VIDE);            
    }catch (Exception $e) {
        return FALSE;        
    }
  • 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-05-28T19:05:57+00:00Added an answer on May 28, 2026 at 7:05 pm

    You can’t catch a PHP error or warning as it is not an exception.

    You can test, after calling unpack, if an error was raised with error_get_last(), but that’s not really practical.

    Another solution is to set an error handler to catch the warning, and then throw an ErrorException for that warning. You will then be able to use try/catch and return false;.

    function my_error_handler($errno = 0, $errstr = null, $errfile = null, $errline = null) {
        // If error is suppressed with @, don't throw an exception
        if (error_reporting() === 0) {
            return true; // return true to continue through the others error handlers
        }
        throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
    }
    set_error_handler('my_error_handler');
    

    Attention: all you errors, warnings, notices, etc… will be converted to an exception. That can potentially crash your program if you had one of those before.

    Now you can catch the exception:

    try {
        $COLOR = unpack("V",substr($IMG,$P,3).$VIDE);            
    } catch (ErrorException $e) {
        return false;        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently transitioned my companies website over to our in-house servers (Apache) from a
We are migrating to Richfaces 3.3 to Richfaces 4.2 and getting following error. Our
About twice a day we get a NullPointerException in our build: [06:44:23]: [ERROR] Failed
We recently upgraded our PHP and apache versions on our server. Prior to this
All, Atlast had our admin install the PEAR SOAP module on our apache server.
Our current Apache installations are running Apache 2.0. Now we'd like to add some
I'm writing a python script to extract data out of our 2GB Apache access
A few months back my team switched our source control over to Apache Subversion
I have been looking into IKVMing Apache's FOP project to use with our .NET
We use Windows for our development systems. I am installing PHP, Apache, MySQL manually.

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.