|
-
Apr 16th, 2005, 09:26 PM
#1
Thread Starter
Hyperactive Member
Apache ASP/PERL/MySQL
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:
<%
use DBI;
my $db = 'DBI:mysql:DBName:localhost';
my $username = 'user';
my $pass = 'pass';
my $db_object = DBI->connect($db, $username, $pass);
my $sql = qq{ SELECT name, age FROM names };
my $sth = $dbh->prepare($sql);
$sth->execute;
my @array = $sth->fetchrow_array;
$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.
Last edited by Disiance; Apr 19th, 2005 at 12:05 PM.
"I don't want to live alone until I'm married" - M.M.R.P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|