Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP and error lines

     

ahmedtheking

10:58 am on Jan 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a var in the php.ini file that allows PHP to count HTML lines as well as the PHP lines when returning the line at which an error has occurred? I'm getting bored of having to search for the line when PHP says there's an error at X when it's actually at X+300!

jatar_k

1:02 pm on Jan 9, 2007 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



that should only happen if you are including, if it is all in the same file it should return the exact line

cmarshall

1:52 pm on Jan 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never had a problem with inaccurate error lines. What am I doing right?

coopster

7:26 pm on Jan 9, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Me too. I mean, I agree. Even in an included file the line number of the error is reported accurately as the line number in the included file. It's not sinking into my thick skull for some reason and I must be missing something ... can you offer more detail?

CDNQuilter

3:01 am on Jan 10, 2007 (gmt 0)

10+ Year Member



When your error is 300 lines away it is usually because you have forgotten a quote or some such and the parser just keeps chugging until it cannot to any further -- sometimes it is amazing how far it goes.

I try to make a few changes and test and so on so that it is easy to back out a change or to see what is happening.

Hope this helps
jean

ahmedtheking

4:20 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well it's not like I've forgotten a quote at line 4 and it's picked it up at line 300 where the quotation ends, it's like this

<somehtml>
<? if (empty($e)) {

php stuff, you know

}?>
<somemorehtml>
<? if (avar) { some more php?>

Now I've forgotton the dollar in front of avar, but it'll tell me the error's about 7-10 lines above. I've been a bit specific by saying 7-10, but it's always above, and not like 1 or 2 lines. This doesn't happen on pages that have just php code.

alfaguru

7:26 pm on Jan 10, 2007 (gmt 0)

5+ Year Member



Are you using an editor with word wrapping on? Some editors count wrapped lines, which will mean a discrepancy in the line count. Try turning word wrapping off.

BarryStCyr

7:54 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



I have the same problem. I can use FrontPage or Notepad with word wrap turned off and I get the same line problem. In Notepad I have to manually count the lines of course, but the line count is still off.

justageek

9:43 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This doesn't happen on pages that have just php code.

So it sounds like it is ignoring the html code and not counting those lines at all. My guess is that if you added the lines of html code to the error line number you'll have the editor line number. Not saying that is a solution to your problem but may explain the discrepency.

JAG

StupidScript

10:21 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well it's not like I've forgotten a quote at line 4 and it's picked it up at line 300 where the quotation ends
When this condition occurs, I've usually seen that it is irrelevant where the quotation ends. Here's an example:
01 <?
02 $somevar = "string variable;
03?>
04-15 <somehtml>
16 <?
17 $somevar2 = "another string variable";
18?>

The error will be reported on line 17 even though the real error is on line 02.

In the case of a missing dollar sign, unless there is an earlier error, that's the error line reported. I really haven't noticed misleading line number reporting. Confusing, sometimes, but when I trace the error back to its source (line 02, above) it all makes sense.

[edited by: StupidScript at 10:24 pm (utc) on Jan. 10, 2007]

ahmedtheking

11:47 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My editor has wrapping on, but displays the line numbers. Is there anything in the PHP.ini I can change? Or am I just being dumb? When the next error occurs, I'll post it!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month