Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Images

by sch (Pilgrim)
on Oct 24, 2002 at 10:48 UTC ( [id://207663]=note: print w/replies, xml ) Need Help??


in reply to Images
in thread Images

OK - if you can put your code in <CODE> tags, it's a bit easier to read, like this:

#!/usr/bin/perl use DBI; $user="mydb1"; $password="mydb1"; print "Content-type:text/html\n\n"; my $dbh = DBI->connect("dbi:mysql:mydb", $user, $password) or die "Can +'t connect to $data_source: $DBI::errstr"; print "successful connection\n"; my $sth = $dbh->prepare( q{SELECT sno, name FROM IMAGE}) or die "Can't + prepare statement: $DBI::errstr"; my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr"; print "Query will return $sth->{NUM_OF_FIELDS} fields.\n\n"; print "Field names: @{ $sth->{NAME} }\n"; while (($sno, $name) = $sth->fetchrow_array) { print "$name: $phone\n"; $line="<img src=".$name; $line=$line." >"; print "<img src=\"$line\">"; } $dbh->disconnect; print "succefully disconnected\n"; print "</body></html>\n";

OK, so looking at the code, here's my thoughts:

  1. first of all, I'm going to repeat this - get used to CGI.pm, it'll make your life a lot easier.
  2. use strict - will catch a lot of errors, such as no definition of $phone
  3. You've got no <body> tag.
  4. There's no <P> tags surrounding your text
  5. You're generating HTML that looks something like <img src="<img src="filename">"> in the while loop

Hey, if there's code up ^^ there ^^, don't blame me if it doesn't work.

But today you took me walking, Through a land that we have lost,
While our children sit at websites, With no access to the cost

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found