http://qs321.pair.com?node_id=234299


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.