By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,341 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

Script error message is referencing wrong line of code

P: n/a
Im developing php pages under apache and Mac OS X. When I have a
scripting error, the error page says...

....error occurred at line 139

Problem is that line 139 is blank and the bad code is really on line
142. Its usaully off by random numbers so I cant just add/subtract a
couple of numbers to guess the real line of problem code. This is a
pain and is slowing me up for trouble-shooting scripts. Any
suggestions? Is this a php.ini setting? -Nick
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I noticed that Message-ID:
<ce**************************@posting.google.com > from Nick contained
the following:
...error occurred at line 139

Problem is that line 139 is blank and the bad code is really on line
142. Its usaully off by random numbers so I cant just add/subtract a
couple of numbers to guess the real line of problem code.


That happens a lot. The error will not show until the script gets to a
point where the lack of something makes a difference. This could be
many lines away from the point where the error was made.

All part of the joys of debugging...

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Nick wrote:
Im developing php pages under apache and Mac OS X. When I have a
scripting error, the error page says...

...error occurred at line 139

Problem is that line 139 is blank and the bad code is really on line
142. Its usaully off by random numbers so I cant just add/subtract a
couple of numbers to guess the real line of problem code. This is a
pain and is slowing me up for trouble-shooting scripts. Any
suggestions? Is this a php.ini setting? -Nick


Imagine the following (bad) function that takes an integer and returns
the sum of all integer from 1 to the one specified:
1 <?php
2 function sum_integer($n) {
3 $total = 0;
4
5 if ($n > 0) {
6 while ($n) {
7 $total += $n;
8 $n -= 1;
9 # } // error here
10 return $total;
11 }
12 return 0;
13 }
14
15 ?>
16

PHP will report the error at line 17! line 17 is not even part of the
file!!
Debugging is a very interesting activity :-)

/me loves debugging
/me loves programs/scripts that do not work :-)))
[disclaimer: mostly when those program/scripts are my own]

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3

P: n/a
"Nick" <nb********@hotmail.com> wrote in message
news:ce**************************@posting.google.c om...
Im developing php pages under apache and Mac OS X. When I have a
scripting error, the error page says...

...error occurred at line 139

Problem is that line 139 is blank and the bad code is really on line
142. Its usaully off by random numbers so I cant just add/subtract a
couple of numbers to guess the real line of problem code. This is a
pain and is slowing me up for trouble-shooting scripts. Any
suggestions? Is this a php.ini setting? -Nick


Line wrapping, perhaps?
Jul 17 '05 #4

P: n/a
Hey guys, thanks for responding. I finally found out the answer. My
editor (Dreamweaver) had line breaks set for Mac OS. Changing line
breaks to Unix or Windows fixed the problem. Relief! -Nick
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.