in reply to Re: passing variables to a sub
in thread passing variables to a sub
nice. thanks for all of that.
it was late (err early), so i missed chromatic et al's suggestion that if didn't reassign $_. however, the if was getting unwieldy and just didn't look good assigning the param to the scalar so i didn't want to do it like that. in the end, i did this:
if ( $cgi->param ) { $sortby = defined ( $cgi->param( 'sortby' ) ) ? $cgi->param( 'sortby' ) : "name"; $ascdesc = defined ( $cgi->param( 'ascdesc' ) ) ? $cgi->param( 'ascdesc' ) : "desc"; $letter = defined ( $cgi->param( 'letter' ) ) ? $cgi->param( 'ascdesc' ) : " "; ownertbl( $sortby, $ascdesc, $letter );
which works fairly well but always ends up true (i think) this is because i am defining my cgi vars in all requests to keep my state (so that if one thing changes everything else doesn't go away). maybe i'll try and test $($cgi->param( 'whatever' )) > 0 and see if i can make this work.
my other issue is the sql paren is doubling up per:
[Sat Oct 16 11:04:23 2010] [error] [client 192.168.15.177] DBD::mysql: +:st execute failed: You have an error in your SQL syntax; check the m +anual that corresponds to your MySQL server version for the right syn +tax to use near 'WHERE name LIKE '%'' at line 3 at /var/www/cgi-bin/o +wnertbl.pl line 76., referer: http://192.168.15.222/cgi-bin/ownertbl. +pl [Sat Oct 16 11:04:23 2010] [error] [client 192.168.15.177] DBD::mysql: +:st fetchrow_hashref failed: fetch() without execute() at /var/www/cg +i-bin/ownertbl.pl line 79., referer: http://192.168.15.222/cgi-bin/ow +nertbl.pl [Sat Oct 16 11:04:23 2010] [error] [client 192.168.15.177] base = http +://192.168.15.222/cgi-bin/ownertbl.pl, sort = ORDER BY name, sortby = + name, ascdesc = , letter = WHERE name LIKE '%', referer: http://192. +168.15.222/cgi-bin/ownertbl.pl
but, i haven't really studied your sql suggestions so i'm hoping with a closer look at that i'll be able to fix this too.
thanks for the help
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: passing variables to a sub
by graff (Chancellor) on Oct 17, 2010 at 00:49 UTC |