Results 1 to 6 of 6

Thread: Adventures in Scripting

  1. #1
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default Adventures in Scripting

    I'm sure a lot of you -if not all- have had one of those moments of revelation that not only solved your problem, but also pointed out how stupid you'd been.

    Feel free to share them.

    I wrote a script last week (a php class to dynamically pull database info and build an input form, but that's not really important), and finally got around to testing it.

    Load it up, view the page.
    Parse error: parse error, unexpected { ... blah,blah,blah. Find line 58, move the curly bracket one space to the left. Try again.

    Nothing!

    What? why not? reload again. Still nothing. View source: completely blank.

    Add a few echo 'line #...'; to try and see where it's stopping. Still nothing. Am I even getting the script?

    Add echo 'start'; on the first line of the __construct() function. Nothing! I thought this was so well arranged, I was quite confident that there wouldn't be any problems. Desperate, I put the syntax error back in: The error message shows. So, I'm parsing the script. Why won't it do anything?

    ?
    ?
    ?

    The eventual solution? Add
    PHP Code:
    new class(); 
    at the top


  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    I once wrote a function for including external content using innerHTML. It worked fine in all browsers. Then I wanted to replace innerHTML with pure DOM methods. It worked smoothly in all browsers except Chrome. I spent 5 or 6 hours to solve the problem. No luck until I realized that my document-for-testing didn't have a valid DOC type. I provided it with a valid DOC type... and my include function worked fine in Chrome too. Stupid!!!
    ===
    Arie (Molendijk).

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

    Default

    I don't remember all the details, but a couple weeks ago I was frustrated trying to get a different result from my page and I was working at it for about 10 minutes doing various levels of testing. Since it was a complex setup I worked my way up to a higher and higher level of debugging. At first, right in the algorithm, then in the function, etc. Finally I reached the top of the the script added echo "test" and nothing appeared. So I tried to figure out what was going on and then I realized that I was editing a local copy of the file. That was fun.
    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
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by djr33 View Post
    So I tried to figure out what was going on and then I realized that I was editing a local copy...
    lol - I hate that! Every once in a while I save something and then later decide to copy it to some other folder - I finish writing, and then end up trying to use the old version (which, for some reason, I didn't DELETE!!!)

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

    Default

    Something's wrong with my brain today.

    I just spent 10 minutes trying to debug a PHP script when str_replace() wasn't working.

    I tried lots of things and recreated the environment for testing outside of the function.

    Then after staring at it for another 2 minutes I realized I hadn't saved it-- I was just doing str_replace() by itself and not saving it back to the variable.

    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
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    I'm working on an assignment for class right now, and I wrote two functions called slideleft() and slideright() that are fired up by two links. When I tested the code, the "right" part worked just fine, but the "left" one was a bit strange; it worked, but not in the correct order. Since I had some complicated calculations in the functions, I had to spend about ten minutes going through them to check if they were right (pain). Turns out when I copied the onclick event from one link to the other, I forgot to change it from "right" to "left" so both links were firing up the same function! Gaaahhh...

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
  •