I'm attempting to set up a MySQL database on an Apache server using Apache::ASP, I've never used PERL before in my life, but I am used to C++/PHP/VB syntaxes so I expect it shouldn't be to difficult to wade through. My question is how do I connect to my MySQL database and output the data? I've tried three different coding sniplets, and have come up with this so far:
Code:
Code:
<%
use DBI;
my $db = 'DBI:mysql:DBName:localhost';
my $username = 'user';
my $pass = 'pass';
my $dbobject = DBI->connect($db, $username, $pass);
my $sql = qq{ SELECT name, age FROM names };
my $sth = $dbh->prepare($sql);
$sth->execute;
my @array = $sth->fetchrowarray;
$dbh->disconnect();
%>
(I've changed the DBName/user/pass to the real values in my code)
The server is telling me the $dbh variable is not globally defined so I can't use it, changing it to "my $dbh" brings an error saying it is undefined.
Enter your message below
Sign in or Join us (it's free).