Log in

View Full Version : Adventures in Scripting



traq
04-29-2010, 08:01 PM
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. :D

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

new class();at the top

:rolleyes:

molendijk
04-29-2010, 11:38 PM
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).

djr33
04-30-2010, 01:39 AM
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.

traq
04-30-2010, 03:57 AM
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!!!)

djr33
05-05-2010, 05:43 AM
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.

:)

Snookerman
05-05-2010, 04:04 PM
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...