Link to home
Start Free TrialLog in
Avatar of Russelauto
RusselautoFlag for United States of America

asked on

Code breaks with the number 14

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.
Avatar of hernst42
hernst42
Flag of Germany image

please show use the code which fails.
Avatar of 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......

;-)

Cheers!
Avatar of Russelauto

ASKER

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)
switch($n){
case 7:
do this;
break;
case 14:
do that;
break;
}
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!
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> 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.