Code breaks with the number 14

Posted on 2007-10-09
Last Modified: 2007-10-09
I have written a small one page php page that generates an image. Here's the problem, everything works fine until I have the integer 14 anywhere in my code. If the number 14 is present, it breaks my images (red X) until something is selected in the html form and then it works when called on. If you call on it with no selections in the html form it breaks again. I have tested this scenario using  three different methods. A while loop, a conditional statement, and a case statement. No matter what, if THE NUMBER 14 is present ANYWHERE in the code it breaks the image until something is selected to use that portion of the code. Makes no sense to me. I don't even think this will be answered but I am stuck and thought I'd give experts a try. If I could give a 1000 points for this one... I would.
Question by:Russelauto
    LVL 48

    Expert Comment

    please show use the code which fails.
    LVL 34

    Expert Comment

    by:Beverley Portlock
    Can you point us at the website in question or at least post some code? We may be hot on PHP but we're all weak on telepathy......



    Author Comment

    I like that, your weak on telepathy. Seriously I laughed when I read that! OK the site is not live even if it was you would just see the red x. The code is real short and simple. Example:
    $im = imagecreatefrompng("image.png");
    $n = count($array)
    case 7:
    do this;
    case 14:
    do that;
    If it any of the case values are met ie: 7 or 14 it works fine. If none... it breaks. But don't focus on the code. Let me re-state the question. Has anyone ever had an integer break something merely by being present in the code?
    comment out the 14...  // case 14: or even change the 14.... case 18: and everything works rather the case values exist or not. This is an anomoly. Has anyone ever run into something like this before? Assume it's not a syntax error, it's not a method error, it breaks when 14 is seen PERIOD. I swear this to be true. I can place the 14 anywhere and is breaks. It doesn't have to be in a function. It can be a one liner....     if ($n == 14) {}   IT BREAKS!
    LVL 48

    Accepted Solution

    Guess it's an error happen which breaks the image-coding. If that happen right-click on the image->View Image and then On the new opened image View the Source of the Image and look which php-errors/notices are mentioned in the file.
    LVL 24

    Expert Comment

    >> Has anyone ever had an integer break something merely by being present in the code?
    Yes, if the code is incorrectly handling the presence of such an integer. This could include:
     - Expecting a different value
     - Expecting a different data type
     - Logic error based on the value

    >> don't focus on the code.
    We *have* to focus on the code. We can say with confidence that this is not a PHP engine error, so there must be something in the code that is causing this problem. Please post your code exactly as it exists in your script. Also include the exact error message that you receive ("it breaks" could mean any number of different things).

    Author Comment

    Your suggestion led me to discover the error that is being produced. It somehow is related to an implode function that's being called on. Now I can focus my efforts on the error instead of the anomoly. Thanks hernst.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now