Re: How to get data from MySQL with perl

2002-06-05 Thread Eivind A. Sivertsen

Here's an example:
-

#! /usr/bin/perl

use Mysql;

$dbh = Mysql-connect(localhost, verycooldatabase, , );

$query = select this from that;
$sth = $dbh-query($query);

// returns one row at the time in array @arr
while(@arr = $sth-fetchrow) {
 foreach $data (@arr)
  print($data\n);
}


-
Good luck!

Eivind


sql, query


-
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




How to get data from MySQL with perl

2002-06-04 Thread Anton

How do I query a database with Perl - retrieve a item and then have that
as a var to use in another insert statement

Currently I have :

Use DBI

I define: my vars : host,db,username,password etc

I create my db object etc


I used the script to do a insert to my db and it worked fine - but I
cant get data from a table with a SELECT * table WHERE whatever)

I don't know excactly how to tel perl how to get the field as a var.




Any help welcome - any good Perl tutorials out there  ?



-
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