/    Sign up×
Community /Pin to ProfileBookmark

Errors on line number – wrong line

I’m new to php. But when I test some code, I can’t find the errors.

example:

Parse error: syntax error, unexpected ‘=’ in /Applications/MAMP/htdocs/nubJOB/admin.php on line 172

And it turns up on a line no where near that. I’m a real clumsy code writer and make a lot of errors. Is that how the line numbers are supposed to work? I really don’t like playing Where’s Waldo with all this code. I could get things done alot faster if I could pinpoint my errors easier. I’m using MAMP and Dreamweaver.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 29.2008 — It's difficult to respond without a specific example of the code. However, sometimes a parse error will cite the line where the parser got to when it figuratively threw up its hands in disgust and said, "I give up!" Sometimes a missing quote, bracket, or semi-colon can screw things up without actually causing the code to be syntactically invalid at that point; and it's not until later where something cannot be parsed because of that actual error somewhere earlier in the code.

But this is all speculation on my part without knowing your specific circumstances. For all I know, DreamWeaver does something funky with the way it handles the wrapping and numbering of long lines?
Copy linkTweet thisAlerts:
@jacjil2authorMay 30.2008 — I don't have any specific problem right now. I was just wondering why the line number in error messages is sometimes off up to 23 lines away. Usually when I forget that variables can't have hyphens in them. I was hoping there was an easier method to find an error. My method if the error is not on the spot indicated in the message is to just go up a few lines and insert a line break and see if the line number in the error changes. It can be very gruling and totally kills the mood when I've gone all day without errors.

Anyway, Dreamweaver just shows 1,2,3 from top to bottom and skips the extra lines caused by wrap.
Copy linkTweet thisAlerts:
@tracknutMay 30.2008 — Anyway, Dreamweaver just shows 1,2,3 from top to bottom and skips the extra lines caused by wrap.[/QUOTE]

I wonder if that's your problem. After all, the *are* lines, regardless of the reason they exist...

Dave
Copy linkTweet thisAlerts:
@jacjil2authorMay 30.2008 — Well. I'm guessing it's what Nogdog said.
sometimes a parse error will cite the line where the parser got to when it figuratively threw up its hands in disgust and said[/QUOTE]

I played around with making errors on purpose and the counts are different every time, but the line always follows the error, never before it. I was hoping for a pattern or something to zero in on the actual syntax error and not the error caused by the faulty syntax. I'm used to Dreamweaver, and I like. I don't think it would steer me wrong. Idk. Maybe loyalty can be stupidity, but...
Copy linkTweet thisAlerts:
@NogDogMay 30.2008 — All I know is since I've started using PHPDesigner with it's as-you-type syntax checker, I spend a lot less time hunting down stupid typos on my part and most syntax errors. (It's not the only IDE with that kind of error-checking, just the one I happen to use now.)
Copy linkTweet thisAlerts:
@felgallMay 30.2008 — If you have an extra { in line 1 of a 10,000 line script then the parser will give an error about mismatched {} on line 10,000 because that will be were it will have got to when it detects that there is an error. The line number is where it got to when it realised that there was an error, it has no way of telling on exactly which line before that the error actually occurred. For the example it doesn't know if the error is an extra { on line 1 or a missing } on some line between 1 and 10,000, all it knows is that it got to line 10,000 and there was no } to match one of the {
Copy linkTweet thisAlerts:
@jacjil2authorJun 01.2008 — By this logic, shouldn't the number be after the type-o then? I'm sometimes getting it from lines before. Is my mamp's ini screwey somehow?
×

Success!

Help @jacjil2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...