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: Beginner:
Access a database using Perl across a LAN

 



Troy
Novice

Jan 22, 2003, 1:04 PM

Post #1 of 2 (781 views)
Access a database using Perl across a LAN Can't Post

I am trying to get a CGI Script working from a client machine on my LAN but have been unsuccessful.
My configuration consists of 2 PC's. A Linux Server (hostname: infoserve.linpc, IP: 10.0.0.1) and a win98
client (hostname: infoserve.winpc, IP:10.0.0.2) Both are networked correctly together and I currently have
no network issues. I can browse a web page from "winpc" no problem and execute cgi-scripts successfully also.

I have setup a simple test database on the server called "cars", with one table called "adverts" and have given
user access to a user called "fred" with the password "fred". On my client machine (winpc) I have a program
called "MySQL Front" which allows me to administer a database remotly. I can connect to the database "cars"
without problem and can modify it also, thus verifying remote ability to access the database.

My problem is that I am new to perl and am having problems getting my script to operate correctly. I simple want
to "SELECT * FROM adverts". I can successfully run other scripts from the cgi-bin where I locate the MySQL perl code.
I am pretty sure that I have the correct modules installed on my server but need to verify this.
The modules installed are as follows:

# rpm -qa | grep mysql
----------------------------
mysql-3.23.41-1
mysqlclient9-3.23.22-6
mysql-server-3.23.41-1
mysql-devel-3.23.41-1

# rpm -qa | grep perl
----------------------------
perl-5.6.0-17
perl-DBI-1.18-1
perl-DBD-MySQL-1.2216-4
mod_perl-1.24_01-3
perl-Data-Dumper-2.09-1
perl-DBD-Pg-1.01-1

My questions are:

1. Do I have the right "tools" / modules to undertake this task?
2. Is it possible to test my configuration and access the database before I leap into the Perl Code?
3. Could anyone suggest a link / tutorial with a snippet of code which allows me to access a database
and simply grab a row of data. Perferably the absoulte minimum code possible to achieve this would
be fantastic!!!

It's possible my existing code is complete crap, and I just need to get up to speed with perl!

Thanks,
- Troy


Jasmine
Administrator / Moderator

Jan 22, 2003, 3:07 PM

Post #2 of 2 (779 views)
Re: [Troy] Access a database using Perl across a LAN [In reply to] Can't Post


Quote
1. Do I have the right "tools" / modules to undertake this task?

Looks like you do.


Quote
2. Is it possible to test my configuration and access the database before I leap into the Perl Code?

Yes, you can access dbi from your command prompt. Please see [url=http://www.mysql.com/doc/en/Windows_running.html]http://www.mysql.com/doc/en/Windows_running.html for examples.


Quote
3. Could anyone suggest a link / tutorial with a snippet of code which allows me to access a database and simply grab a row of data. Perferably the absoulte minimum code possible to achieve this would be fantastic!!!

A couple of quick links:

For a little bit more... the [url=http://search.cpan.org/author/TIMB/DBI-1.32/DBI.pm]DBI documentation would be a good start to learn how to use it with perl, and the [url=http://www.mysql.com/doc/en/index.html]mysql documentation would be a good place to start learning mysql.


Quote
It's possible my existing code is complete crap, and I just need to get up to speed with perl!

Please post some code Smile

 
 


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

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