CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
MYSQL Error

 



crashinto
Novice

Nov 24, 2001, 4:29 AM

Post #1 of 1 (282 views)
MYSQL Error Can't Post

I am getting an error with this code right here saying "Can't locate object method "connect" via package "DBI" (perhaps you forgot to load "DBI"?) at site_html.cgi line 273."

But I am using the same connect to mysql I am for another sub in the exact same file and that sub works. And I did close that to.


Code
sub viewitem_html { 

my $dbh = DBI->connect("DBI:mysql:database=crashint_test;host=localhost",
"crashint", "PASSWORD",
{'RaiseError' => 1});

my $sth = $dbh->prepare("SELECT * FROM items");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {

print qq| <CENTER><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="75%"><TR><TD WIDTH="10%"> |;

if ($ref->{'isimage'} eq 'yes') { print qq|<a href="$ref->{'additemimage'}" TARGET="_NEW"><IMAGE SRC="$ref->{'additemimage'}" HEIGHT=75 WIDTH=75></a>|; }
else { print qq|<IMAGE SRC="$images/noimage.jpg" HEIGHT=75 WIDTH=75>|; }


print qq|</td><td align=center width=10% valign=middle>|;

if ($inve > 1) { print qq|Item is in stock.|; }
else { print qq|Item is not in stock.|; }


print qq|</td><td align=center width=10% valign=middle><a href="$viewitemurl?itemnum=$ref->{'num'}">$ref->{'item'}</a></td><td align=center width=10% valign=middle>\$$ref->{'price'}</td><td width="70%" valign=middle>$ref->{'desc'}</td></tr></table>
<FORM ACTION="$viewcarturl" METHOD=POST>|;

if ($ref->{'shirt'} eq 'yes') {
print qq|<b>What size do you want to order?</b> <SELECT NAME="size">|;

if ($ref->{'size'}) {
print qq|<OPTION value="$ref->{'size'}">$ref->{'size'}</OPTION>|;
}
if ($ref->{'size2'}) {
print qq|<OPTION value="$ref->{'size2'}">$ref->{'size2'}</OPTION>|;
}
if ($ref->{'size3'}) {
print qq|<OPTION value="$ref->{'size3'}">$ref->{'size3'}</OPTION>|;
}
if ($ref->{'size4'}) {
print qq|<OPTION value="$ref->{'size4'}">$ref->{'size4'}</OPTION>|;
}
if ($ref->{'size5'}) {
print qq|<OPTION value="$ref->{'size5'}">$ref->{'size5'}</OPTION>|;
}
if ($ref->{'size6'}) {
print qq|<OPTION value="$ref->{'size6'}">$ref->{'size6'}</OPTION>|;
}
print qq|</SELECT><BR>|;

print qq|<b>What color do you want to order?</b> <SELECT NAME="color">|;

if ($ref->{'color'}) {
print qq|<OPTION value="$ref->{'color'}">$ref->{'color'}</OPTION>|;
}
if ($ref->{'color2'}) {
print qq|<OPTION value="$ref->{'color2'}">$ref->{'color2'}</OPTION>|;
}
if ($ref->{'color3'}) {
print qq|<OPTION value="$ref->{'color3'}">$ref->{'color3'}</OPTION>|;
}
if ($ref->{'color4'}) {
print qq|<OPTION value="$ref->{'color4'}">$ref->{'color4'}</OPTION>|;
}
if ($ref->{'color5'}) {
print qq|<OPTION value="$ref->{'color5'}">$ref->{'color5'}</OPTION>|;
}
if ($ref->{'color6'}) {
print qq|<OPTION value="$ref->{'color6'}">$ref->{'color6'}</OPTION>|;
}
print qq|</SELECT><p>|;

}
else { print ""; }


print qq|
<INPUT TYPE=hidden name=itemnum value="$FORM{'itemnum'}">
<INPUT TYPE=hidden name=affiliate value="$FORM{'affiliate'}">
Quantity: <INPUT TYPE=text name=quantity>
Username: <INPUT TYPE=text name=username>
Password: <INPUT TYPE=password name=password>
<INPUT TYPE=submit value="Add to Cart">
</FORM>
|;
}
$sth->finish();


# Disconnect from the database.
$dbh->disconnect();

}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives