Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Multiple Script calls

by cees (Curate)
on Feb 11, 2003 at 02:35 UTC ( [id://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.
    cidaris

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-20 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found