We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!


Code breaks with the number 14

Russelauto asked
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.
Watch Question

Top Expert 2007

please show use the code which fails.

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......




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!
Top Expert 2007
Unlock this solution and get a sample of our free trial.
(No credit card required)
>> 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).


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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.