Results 1 to 9 of 9

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

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default what do you use to count lines in a script to find the error you are gettin in a ..

    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.

    Thanks,

    Bud

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    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.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    (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.
    Last edited by djr33; 01-28-2011 at 04:45 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    To add to the list, I love Text Wrangler for Mac OSX:
    http://www.barebones.com/products/textwrangler/

    Notepad++ is also popular (I think only for Windows.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default Thanks everyone!

    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).

    thanks,

    Bud

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default the guy that owns/runs the company I use to host my

    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.

    Thanks,

    Bud

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •