in reply to Re: Cannot run a simple script?help im new
in thread Cannot run a simple script?help im new

Thanks all for your help
I have tried to implement what you guys have advised heres the code:

#!c:/perl/bin/perl -wT

use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use vars qw($Query $sth $dbh $Value @results @row);
$Query = new CGI( );
use DBI;
$dbh = DBI->connect('DBI:mysql:exelstock')
or die "Cannot connect: " . $DBI::errstr;

$Value = $Query->param('input');


$sth = $dbh->prepare("SELECT * FROM stock WHERE name=$Value");
$sth = $dbh->execute();
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY>\n";
while (@results = $sth->fetchrow_array) { print "@row\n";
}
$sth = $dbh->finish();
$dbh->disconnect();
print "</HTML>\n";
print "</BODY>\n";


Heres the error i get now...any ideas???

Can't locate object method "execute" via package "DBI::db" at c:\PROGRA~1\APACHE~1\apache\cgi-bin\project2.cgi line 23.
  • Comment on Re^2: Cannot run a simple script?help im new

Replies are listed 'Best First'.
Re^3: Cannot run a simple script?help im new
by Tanktalus (Canon) on Mar 02, 2005 at 04:27 UTC

    That's simply because, as the error message says, DBI::db doesn't have an execute method. Try changing it from $sth = $dbh->execute(); to $sth->execute();

    Also, please use code tags when posting code. Thanks.