Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Multiple Script calls

by cees (Curate)
on Feb 11, 2003 at 02:35 UTC ( #234299=note: print w/replies, xml ) Need Help??

in reply to Multiple Script calls

Can't really see anything that would cause problems... I would pepper the code with debug statements and look at the log files to see where things are dying.

I have couple of comments on the code itself though. You really should remove the use CGI::Carp('fatalsToBrowser'); since this script returns an image and fatalsToBrowser generates HTML. And more importantly, you should be using placeholders in your SQL statement. You take a value provided by the browser and plug it straight into your SQL statement without checking anything. Changing it to something like the following will make things much safer:

my %IMG_FIELDS = { field1 => 'Field1', field2 => 'Field2', }; die "Invalid img parameter $img" unless $IMG_FIELDS{$img}; my $sql = "SELECT $IMG_FIELDS{$img} FROM listings WHERE pc_mls_id = ?" +; my $sth = $dbh->prepare($sql) or die "Couldn't prepare: $DBI::errstr\n"; $sth->execute($mls_id);

You can't use a placeholder to select a column dynamically (at least my quick test in PostgreSQL didn't allow it), so we use a lookup table for that one. For the pc_mls_id we use a placeholder. The value automatically gets quoted by DBI to protect it from any nasties that your users may put in there.

Replies are listed 'Best First'.
Re: Re: Multiple Script calls
by cidaris (Friar) on Feb 11, 2003 at 02:38 UTC
    Using placeholders in the scripts that call this 'image_serve' and in the script that actually allows the database to be modified... Skipped placeholders in this one to keep it slightly simpler. Will replace them later.

    Thanks for the tip, though.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://234299]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2023-06-07 02:27 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.