Re: How to access MySql using Perl. Help

2002-02-12 Thread lcalero


 I am new to MySql. I have MySql installed in my Linux PC.  How do I connect
 to MySql using Perl script and assign the result of a query to an array?
 Where could I find a sample code?  Thank you.

  man DBD::mysql

  Cheers.

--
  Luis Calero Muñoz
  $email{luis} = '[EMAIL PROTECTED]'
  $who{luis} = 'sysadm at ociojoven dot com'



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: How to access MySql using Perl. Help

2002-02-12 Thread Todd Williamsen

http://www.hotscripts.com

Or

http://www.scriptsearch.com

Both sites show examples on how to contect to a database with perl or
PHP.  They also show how to connect to other databases!

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 3:11 AM
To: Andy Cheng
Cc: [EMAIL PROTECTED]
Subject: Re: How to access MySql using Perl. Help



 I am new to MySql. I have MySql installed in my Linux PC.  How do I
connect
 to MySql using Perl script and assign the result of a query to an
array?
 Where could I find a sample code?  Thank you.

  man DBD::mysql

  Cheers.

--
  Luis Calero Muñoz
  $email{luis} = '[EMAIL PROTECTED]'
  $who{luis} = 'sysadm at ociojoven dot com'



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: How to access MySql using Perl. Help

2002-02-12 Thread Keith A. Calaman

Read through the man doc lcalero gave you it tells everything you need to
know.  Below is a basic example to help get you started:


#!/usr/bin/perl


use CGI;


use DBI;
$hostname = 'www.hostname.com';
$database = 'nameofdatabase';
$user = 'username';
$password = 'password';
$driver   = 'mysql';
$dsn  = DBI:$driver:database=$database;host=$hostname;


my $dbh = DBI-connect($dsn, $user, $password)  or die Cant connect to
the DB:
$DBI::errstr\n;

my $sth = $dbh-prepare(SELECT attributes from entities);

$sth-execute();

my $something;
while (my @row = $sth-fetchrow_array()) {
 $something .= qq|  $row[2]$row[1]etc.\n|;

}

#each row is respective to the row returned from the query with the first
being row 0

$sth-finish;






-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 4:11 AM
To: Andy Cheng
Cc: [EMAIL PROTECTED]
Subject: Re: How to access MySql using Perl. Help



 I am new to MySql. I have MySql installed in my Linux PC.  How do I
connect
 to MySql using Perl script and assign the result of a query to an array?
 Where could I find a sample code?  Thank you.

  man DBD::mysql

  Cheers.

--
  Luis Calero Muñoz
  $email{luis} = '[EMAIL PROTECTED]'
  $who{luis} = 'sysadm at ociojoven dot com'



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: How to access MySql using Perl. Help

2002-02-11 Thread admin

Hi.

You have to install DBI::DBD module.
Then in perl
use Mysql;
$dbh = Mysql-connect(undef,database,username,'password');
$sql = select blah from blah;
$sth = $dbh-query($sql);
@arr = $sth-fetchrow;

for example if the result is more than one line you have to loop it 

Ofcoz there is other ways to do it i guess:)

/PM\
Andy Cheng wrote:
 
 Hello,
 
 I am new to MySql. I have MySql installed in my Linux PC.  How do I connect
 to MySql using Perl script and assign the result of a query to an array?
 Where could I find a sample code?  Thank you.
 
 Andy
 
 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: How to access MySql using Perl. Help

2002-02-07 Thread admin

Hi.

You have to install DBI::DBD module.
Then in perl
use Mysql;
$dbh = Mysql-connect(undef,database,username,'password');
$sql = select blah from blah;
$sth = $dbh-query($sql);
@arr = $sth-fetchrow;

for example if the result is more than one line you have to loop it 

Ofcoz there is other ways to do it i guess:)

/PM\
Andy Cheng wrote:
 
 Hello,
 
 I am new to MySql. I have MySql installed in my Linux PC.  How do I connect
 to MySql using Perl script and assign the result of a query to an array?
 Where could I find a sample code?  Thank you.
 
 Andy
 
 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php