View Full Version : what do you use to count lines in a script to find the error you are gettin in a ..

01-26-2011, 12:34 AM
In a script.

Working with a php script it gives errors on lines (ex. error on line 54)

How do you look at a script and get the lines(by number) so you can go to a specific location and work out the issue ?

I presume just about and scripting type(cgi,javascript,java and others) have this ability built in to the coding to help work out things.



01-26-2011, 01:40 AM
Your text editor should have an option for line numbering. Check there for options first if you post your php code we could try and help you. The numbering can also be off by a few lines or completely off depending on the coding error.

01-26-2011, 02:24 AM
(Note: this response is based especially on PHP errors, but it's somewhat similar for other errors such as HTML, Javascript, etc.)

Very often, the line indicated is the correct line. Less frequently, it is one line above or one line below, due to the way the processing error occurred before/after the actual mistake.

For errors involving general structural problems in the code to the point that the parser cannot determine where they layering went wrong, it will often default to saying the error was at the end of the file.

For errors that occur during a loop, this can cause it to be reported for any line within that loop, in certain circumstances.

I've also found that sometimes the count differs from my text editor, perhaps due to comments or extra whitespace. I've never noticed an exact pattern with that, but it's usually not that hard to deal with.

Memory errors, time-limits, and other system-level errors are reported when they occur, so sometimes these can appear to be random, but in those cases it's often a general problem with the methodology of the script (or a server setting that can be corrected).

If your text editor doesn't have line numbers, you should probably get a new text editor. Most decent text editors have line numbers and it's one of those features users expect, so you're probably missing out of other basics if you don't have it. Note that some text editors don't have the line numbers displayed by default but they can be enabled manually. And in some editors such as Notepad, there are no line numbers but there is a feature "go to line" and you can type in "54" to find line 54.

01-26-2011, 09:40 AM
If your text editor doesn't have line numbers, you should probably get a new text editor here's something that might help if you dont have line numbering: http://www.pspad.com/

01-26-2011, 04:43 PM
To add to the list, I love Text Wrangler for Mac OSX:

Notepad++ is also popular (I think only for Windows.)

01-27-2011, 06:25 PM
I really appreciate the replys and the fact that they were so quick.

I was sick the last two days and did not do a lot then .

I just emailed the guy that hosts my online account and asked him to add the line count ability to my editor.He wrote the current one I am using so I suspect he could easily add that to it for me ( fingers -crossed,lol).



01-27-2011, 11:32 PM
I don't understand how this is related to your host. Most files for webpages (html, css, javascript, etc) are just text files (with different file extensions like .htm, .php, .js, etc.), and the host has nothing to do with this. Of course if you are using an online editor (website) this is different. Or were you just asking your host for advice?

01-28-2011, 12:11 AM
Web site is a friend and and yes,I am using his online editor.

I have never used anything but that.

You see this is a hobby of mine and I do not know much about writing in any of the different scripts,php,cgi,asp or any other ones.

But I can sometimes figure out how to do things by testing/trying out things.

I want to learn more but it is hard when you do not use the correct tool(s) to do things,such as a real editor as you all probally use.

I like most of you become used to using what we have and to make a change is not always a comfortable thing to do.

But I was once told that change takes 21 days to overcome ( not too sure I agree with that though,lol

If I were to use on of the above tools do things get broken or ruined when you save them then upload/download them to the website?

Sorry to be so much of an pain with these questions but I would like to learn more then I know about this stuff.



01-28-2011, 04:49 AM
If you want to get into web design seriously, then using a text editor that has built in FTP functions is great. You can open a file directly from your server (via FTP-- log in, browse, open) and then edit it and save it, all while viewing your site live. It's similar to what you're using now, but a little more powerful.

Of course things can get broken using it, but that's if you do something wrong. Make backups often, and once in a while there might be a need to restore from them. (In reality, this is very rare, but of course it's a big problem if you don't have backups.) Generally the only things that get broken are when you make a mistake, but this just means that you need to correct the mistake. The text isn't lost; it just will be temporarily ill-formed and generate unexpected results.
The only potential problem with this sort of editing is that in order to "save" a file, it actually deletes the file on the server then uploads the new version. In very unusual circumstances, it is theoretically possible that the FTP connection will break while this happens and you will be left with an empty file on the server. But of course you can notice this because your page was not saved and you'll just need to try to save it again.
Generally, these aren't things you need to worry about, but you asked :)

My advice overall is simple: do what works. If you want to get more into web design, try to use some of the more standard tools. If all you need to do is get it done and not worry about anything else, then just do whatever works. But do be aware that as you learn more you will get faster and designing, your websites will improve in features/design, and not only will you learn more about how to fix problems but you'll actually encounter fewer problems as you become more experienced and know how to avoid them.