Perl with Apache ASP

  • 15 years ago

    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->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.

  • 15 years ago
    Hello Disiance,

    Welcome to DeveloperFusion.com!

    I havent touched perl in about 8 years now so I'm very rusty. But i found an article that i think will help you here.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor