Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Sql Issues blank column being called which isnt in the code?

by barrycarlyon (Beadle)
on May 25, 2006 at 12:25 UTC ( [id://551588]=perlquestion: print w/replies, xml ) Need Help??

barrycarlyon has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Sql Issues blank column being called which isnt in the code?
by gellyfish (Monsignor) on May 25, 2006 at 14:20 UTC

    Now you have found the problem by your own means I can divulge the means of diagnosis I was prodding you toward in the CB. The reason you were unable to diagnose the problem was that you are taking too many shortcuts in this code: an error in another part of your application is trickling down and manifesting itself as an error in this line of code because you havent taken steps to prevent this from happening. The first step I would have taken upon getting an error from this code (assuming I would have written it like this in the first place) would be to split it into convenient chunks so each part can be examined separately, so to start:

    my $create_args = {'show' => $q->param('title'), 'password' => $q->param('passw +ord'), 'gamertag' => $q->param('gamer +tag'), 'locations' => $q->param('loca +tions'), 'episodes' => $q->param('episo +des'), 'character' => $q->param('char +acters'), 'description' => $q->param('de +sc'), 'datetime' => Class::Date->now +(), }; Jonbaglo::Database::Clan_Shows->create($create_args);
    At this point you will still get the same error at the same point, but now you are able to examine $create_args using say Data::Dumper before you try to use it. You could do for instance:
    warn Dumper($create_args);
    which should put the data structure in your error log. At this point you would have realized that you were getting a funny data structure and that the probable cause was that some or all of the parameters you were trying to use were undefined.

    You should have been checking the parameters before you were trying to use them in the first place, not just to stop errors like this in your code, but also to prevent your application being exploited by faulty or malicious input.

    /J\

Re: Sql Issues blank column being called which isnt in the code?
by bpphillips (Friar) on May 25, 2006 at 15:32 UTC
    Continuing gellyfish's comment above, if you had warnings enabled (i.e. use warnings) you would have seen:
    Odd number of elements in anonymous hash at line 372.
    While this would not have immediately indicated the source of the problem, it might have motivated you to dump out the data structure at line 372 to see what was going on before throwing your hands up and posting a vague query on this site. Debugging can be a learned skill so hopefully the result of this post is that you learned a little more about problem solving. :-)

    Yet another example of the usefulness of warnings -- even though they can be annoying at times!

    -- Brian

      use warnings is in use, its just not in the code snippet

      Barry Carlyon barry@barrycarlyon.co.uk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://551588]
Approved by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found