[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Code breaks with the number 14

Posted on 2007-10-09
Medium Priority
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

ID: 20041196
please show use the code which fails.
LVL 34

Expert Comment

by:Beverley Portlock
ID: 20041207
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

ID: 20041955
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!
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 48

Accepted Solution

hernst42 earned 2000 total points
ID: 20042021
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

ID: 20042034
>> 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

ID: 20042784
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 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