BARKER, Paul wrote:
Hi All I'm back using CGI::Application after what must be a year or more away doing other stuff so feel free to flame me (gently!) if this is an obvious mistake but ...
Welcome back
sub img_index # Show index of images for a particular hostid { my $self = shift; my $query = $self->query(); my $hostid = $query->param('host'); my $ouptut = ''; my $dbh = $self->param('dbh');my $hostname = $dbh->selectrow_array("SELECT hostname FROM hosts WHEREhostid=?", undef, $hostid);}It seems that anytime I do a $dbh->prepare (which is explicitly called inside the DBI selectrow_array method) I get the output of the prepare in the browser and nothing else. If I access the above via http://myhost/cgi-perl/AEPWeb.pl?rm=imgindex&host=00004 I get the word 'aurora' in the browser. Now while this is the right answer since I'm not actually asking it to output I'm a little confused as to how it gets there.
This is actually because of the way perl works. If there is no return statement at the end of a subroutine, then perl will return the result of the last expression. In your case the last expression was the assignment to $hostname, which perl then returns to the caller. And CGI::App expects the return value of your runmodes to be a string of HTML, so it sends it out to the browser.
So just put an explicit 'return;' at the end of the sub and it will go away. Cheers, Cees
If I write something like $dbh->prepare("SELECT updated, updatedby FROM images WHERE hostid=?"); I get something along the lines of DBI::st=HASH(xxxxxx) in the browser. Does anyone have any idea why this is happening ? Many thanks! Paul Barker ******************************************************************** Important. Confidentiality: This communication is intended for the above-named person and may be confidential and/or legally privileged.Any opinions expressed in this communication are not necessarily those of the company. If it has come to you in error you must take no action based on it, nor must you copy or show it to anyone; please delete/destroy and inform the sender immediately.Monitoring/Viruses.Orange may monitor all incoming and outgoing emails in line with current legislation. Although we have taken steps to ensure that this email and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.Orange PCS Limited is a subsidiary of Orange SA and is registered in England No 2178917, with its address at St James Court, Great Park Road, Almondsbury Park, Bradley Stoke, Bristol BS32 4QJ.********************************************************************
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.