Hi, I am trying to write a small script to fetch a certain record (say record no. 25) from a mysql db.
I have written the following script after reading a Mysql book, but I am not able to understand as to how to fetch a given record no., or get records between a given range... like all records between 24th - 29th ..
A small part of the script...
#!/usr/bin/perl use DBI; use strict; my ($dsn)="DBI:mysql:test:localhost"; my ($dbh,$sth); my (@ary); my ($aaa); my ($bbb);
# Connect to databse $dbh = DBI-> connect ($dsn,{RaiseError=>1});
# Issue query $sth = $dbh -> prepare ("SELECT item1 from list1"); $sth-> execute();
$bbb = $sth->fetchrow; $aaa = $sth->fetchrow; print $bbb; print $aaa;
$sth-> finish (); $dbh-> disconnect (); exit (0);
Can someone please help me.... Thanks in advance.
Poonam
________________________________________________________________________ Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!! visit http://in.autos.yahoo.com
Please use a meaningful subject line. Your subject says absolutely nothing about the problem that you are facing. If it wasn't the only message in my inbox, I might have deleted it without reading.
Read on for the solution.
On Mon, 1 Jul 2002, Poonam P wrote:
I have written the following script after reading a Mysql book, but I am not able to understand as to how to fetch a given record no., or get records between a given range... like all records between 24th - 29th ..
A small part of the script...
#!/usr/bin/perl use DBI; use strict; my ($dsn)="DBI:mysql:test:localhost";
^^^^^^
don't put parentheses here. use parens only when declaring a list of identifiers, like in the line just below.
my ($dbh,$sth); my (@ary); my ($aaa); my ($bbb);
# Connect to databse $dbh = DBI-> connect ($dsn,{RaiseError=>1});
# Issue query $sth = $dbh -> prepare ("SELECT item1 from list1"); $sth-> execute();
$bbb = $sth->fetchrow; $aaa = $sth->fetchrow;
to fetch the 25th row, you will first have to get the first 24 rows and discard them:
for my $i (1..24) { $sth->fetchrow; }
$aaa = $sth->fetchrow; # the 25th row
SQL does not allow you to select a particular record from a database. This is primarily due to the fact that unless you specify an ORDER BY clause in the SELECT statement, there is no specified order in which results will be returned. They need not be returned in the same order that you inserted them.
Halo Amol I tried to configure dns. So i edited /etc/named.conf.
// generated by named-bootconf.pl
options { directory "/var/named"; /* * If there is a firewall between you and nameservers you want * to talk to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an unprivileged * port by default. */ // query-source address * port 53; };
// // a caching only nameserver config // zone "." IN { type hint; file "named.ca"; };
zone "localhost" IN { type master; file "localhost.zone"; allow-update { none; }; };
zone "0.0.127.in-addr.arpa" IN { type master; file "named.local"; allow-update { none; }; };
zone "jnpt.com" { notify no; type master; file "zone/jnpt.com"; };
zone "2.10.190.in-addr.arpa" { notify no; type master; file "zone/190.10.2"; };
key "key" { algorithm hmac-md5; secret "ZpxbilkoNZ0LBoFzRJgBnhaexddrgLcfzGbOL0NCGObhJxOkaFHzJGjwdUXl"; };
Then I created 2 files under /var/named/zone 1.. jnpt.com @ IN SOA jnpt.com. root.jnpt.com. ( 1999070401 ; serial, todays date + today's serial num 8H ; refresh, seconds 2H ; retry, seconds 1W ; expire, seconds 1D ) ; minimum, seconds NS ns MX 10 mail
localhost A 127.0.0.1
intranet A 190.10.2.60
a.. 190.10.2
@ IN SOA jnpt.com. root.jnpt.com. ( 1999070401 ; Serial 28800 ; Refresh 14400 ; Retry re 86400 ) ; Minimum NS ns.jnpt.com.
60 PTR intranet.jnpt.com
My linux m/c is having IP of 190.10.2.60 and on same m/c i am configuring Apache & DNS. From Client machine I am going to access intranet. Intranet address should http://intranet.jnpt.com . Also I added 190.10.2.60 as DNS server entry on windows m/c.
But still It didn't work. Pl. help me.
----- Original Message ----- From: "Amol Hatwar" amolhatwar@rediffmail.com To: linuxers@mm.ilug-bom.org.in Sent: Friday, June 28, 2002 6:21 PM Subject: Re: Re: [ILUG-BOM] Apache configuration
is working fine. I want fully qualified domain name ( www.jnpt.com ) for intranet. I added line in virtual host. but it didn;t work. What is the
[snip] if u just wanna host 1 site...u wouldnt need Virtual servers for that. Virtual servers r for dudes who would like to do multiple domain hosting.
I have fiddled *even crashed* Apache by doing strange things, and I find keeping a virtual host actually helps. Atleast, your apache documentation remains accessible at http://localhost at all times ;).
Well, as for your problem goes Unmesh you can use a DNS server. But the way you ask your question, I guess you haven't set one up. Still, you can get the thing done a DNS server. In the file /etc/hosts, you can add the IP address and the Domain you want.
Also you have set the DNS search order to host and then DNS. This you can do using linuxconf I guess. But remember from wherever you plan to access your intranet site you must make changes there. *manageable if your Network is small enuff*.
Similar settings can be done on your windows based clients as well. All you now have to do is setup up Apache accordingly. Mail me if nothing works :)
Regards,
AH amolhatwar at rediffmail dot com
Hi Unmesh,
Well add these lines too... First of all u have not added IN keyword ... modify ur file as follows..
jnpt.com file ---------------------------------- $ORIGIN com. IN SOA ns.jnpt.com. root.jnpt.com. ( 1999070401 ; serial, todays date + today's ;serial num 8H ; refresh, seconds 2H ; retry, seconds 1W ; expire, seconds 1D ) ; minimum, seconds IN NS ns IN A 190.10.2.60 IN MX 10 mail
$ORIGIN jnpt.com. ns IN A 190.10.2.60 [comment (or wat ever is IP of Server)] mail IN A 190.10.2.60 [""] intranet IN A 190.10.2.60
----------------------------------------------
and the moment u reload the named daemon, you put a tail -f /var/log/named.log
and see if the zone file got loaded properly .... if yes then you are thru, or else u got to check out on google with the particular error it sent out while loading the zone files ....
Hope this helps...
Best Regards, -Mitul Limbani (mitul 2 mitul.com)
My linux m/c is having IP of 190.10.2.60 and on same m/c i am configuring Apache & DNS. From Client machine I am going to access intranet. Intranet address should http://intranet.jnpt.com . Also I added 190.10.2.60 as DNS server entry on windows m/c.