ahh.. many bugs in here actually.. but this one is just one that bugs me..
no one seems to notice multiple selections don't work.. anyhow.. this is related to integer issues..
i was in the middle of developement on a script that counts how many listings a user has and putting them into a field..
well.. i was adding the record using a script i made that is integrated with DBSQL.pm so it uses add_record to add the stuff.. well.. ok.. when you first add the record.. (user).. obviously they don't have any listings.. so.. it should be defaulted to 0.. so i hardcoded it so no one can do any tricky stuff with the query string..
here in this code... the bolden part.. is an example of what happens..
$in_r->{Listings} = 0;
$db->add_record ($in_r);ok... in DBSQL.pm now.. it goes to sub add_record.. it first checks to see if the record is valid.. by sending it to sub _validate_record..
in validate_record.. it checks to see if the record is null.. with this code..
which works great in checking for an empty string.. (or a string with a bunch of white spaces)..
however.. when we get back into add_record after the record is validated.. it checks to see which strings are empty to put into a string to add to a query to add the record to the database.. it checks with this code..
here is the problem.. the number of listings.. was '0'.. 0 is false in PERL.. so it skips to the next field.. and leaves this field BLANK..
instead of getting '0' listings.. i get ''..
the code needs to be..
Jerry Su
no one seems to notice multiple selections don't work.. anyhow.. this is related to integer issues..
i was in the middle of developement on a script that counts how many listings a user has and putting them into a field..
well.. i was adding the record using a script i made that is integrated with DBSQL.pm so it uses add_record to add the stuff.. well.. ok.. when you first add the record.. (user).. obviously they don't have any listings.. so.. it should be defaulted to 0.. so i hardcoded it so no one can do any tricky stuff with the query string..
here in this code... the bolden part.. is an example of what happens..
Code:
my $in_r = &cgi_to_hash ($in); $in_r->{Listings} = 0;
$db->add_record ($in_r);
in validate_record.. it checks to see if the record is null.. with this code..
Code:
$rec_r->{$column} =~ /^\s*$/however.. when we get back into add_record after the record is validated.. it checks to see which strings are empty to put into a string to add to a query to add the record to the database.. it checks with this code..
Code:
$rec_r->{$column} or next;instead of getting '0' listings.. i get ''..
the code needs to be..
Code:
($rec_r->{$column} =~ /^\s*$/) and next;