#!/usr/bin/perl use warnings; use strict; use DBI; #step1 - create connection object my $dsn = 'DBI:mysql:khalid'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; open HAN, "It" || die "No file"; my @newrecords = <HAN>; foreach (@newrecords) { my @col = split; my $first_name = $col[0]; my $last_name = $col[1]; my $job = $col[2]; #step2 - insert/update/delete queries. $conn->do("INSERT INTO khalid(first_name,last_name,job)VALUES('$first_ +name','$last_name','$job')") || die "Error preparing query" . $conn- +>errstr; }
so i want know to figure out my way i made a post before about the webmin and how to make a subset of it and i want agood and simple book that i can start with to help me in that issue ..... THANKS FOR ALL AGAIN :)#!/usr/bin/perl use warnings; use strict; use DBI; #step1 - create connection object my $dsn = 'DBI:mysql:firstDB'; my $dsn2 = 'DBI:mysql:fruit'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; my $conn2 = DBI->connect($dsn2,$user,$password) || die "Error connecti +ng" . DBI->errstr; #step2 - define query my $query = $conn->prepare('SELECT * FROM guests') || die "Error prep +aring query" . $conn->errstr; my $query2 = $conn2->prepare('SELECT * FROM fruits') || die "Error pr +eparing query" . $conn->errstr; #step3 - execute query $query->execute || die "Error executing query". $query->errstr; $query2->execute || die "Error executing query". $query2->errstr; #step4 - return results my @results; my @results2; while (@results = $query->fetchrow_array()) { my $autoID = $results[0]; my $first_name = $results[1]; my $last_name = $results[2]; my $age = $results[3]; my $comments = $results[4]; my $date_entered = $results[5]; print "autoID is : $autoID \n first_name is : $first_name \n last_name + is : $last_name \n comments are : $comments \n date_entered = $date_ +entered \n "; } while (@results2 = $query2->fetchrow_array()) { my $name = $results2[0]; my $colour = $results2[1]; print "the name of fruit is : $name \n the colour of the fruit : $colo +ur\n" } if ($conn->rows == 0) { print "No Records!"; } if ($conn2->rows == 0) { print "No Records!"; }
In reply to thanx for this great forums :) by adam_blackice
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |