Select produces no results? - How to check ?

2001-10-30 Thread Michael Bellears

I have a perl script that selects users dial-up usage based on month/year -
It works fine, but if the selected month/year does not contain any usage
data, the only way I can check is with the following code:

#  $sth-execute() # Execute the query
$my_result = $sth-execute() # Execute the query
or die Couldn't execute statement:  . $sth-errstr;

if ($my_result eq 0E0){
print No data is available for the selected time period;
exit(0);
}
  # The select produced results - Read the matching records and
print them out

  while (@data = $sth-fetchrow_array()) {

The '0E0' came about by just printing the result of $my_result during
successful/non-successful selects.

I'm sure there is a more elegant way to check if a select statement results
in success or not.

Regards,
Michael

Debian Linux 2.2, mysql  Ver 9.38 Distrib 3.22.32, for pc-linux-gnu (i686)

-
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




insert(append) text to multiple fields..

2001-08-15 Thread Michael Bellears

Hi,
 
I have a table with approx 500 encrypted users passwords, and I need to
insert {crypt} at the beginning of each one -
 
eg..
 
Sample password:
 
$dfij98unoc8jew9048urf
 
would become:
 
{crypt}$dfij98unoc8jew9048urf
 
Any suggestions are greatly appreciated.
 
Regards,
Michael



RE: insert(append) text to multiple fields..

2001-08-15 Thread Michael Bellears

Perl.

 -Original Message-
 From: Jeremy Zawodny [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, 15 August 2001 5:04 PM
 To: Michael Bellears
 Cc: '[EMAIL PROTECTED]'
 Subject: Re: insert(append) text to multiple fields..
 
 
 On Wed, Aug 15, 2001 at 04:37:15PM +1000, Michael Bellears wrote:
  Hi,
   
  I have a table with approx 500 encrypted users passwords, and I need
  to insert {crypt} at the beginning of each one -
   
  eg..
   
  Sample password:
   
  $dfij98unoc8jew9048urf
   
  would become:
   
  {crypt}$dfij98unoc8jew9048urf
   
  Any suggestions are greatly appreciated.
 
 What language do you prefer to program in?
 -- 
 Jeremy D. Zawodny, [EMAIL PROTECTED]
 Technical Yahoo - Yahoo Finance
 Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936
 
 MySQL 3.23.29: up 59 days, processed 528,769,163 queries 
 (102/sec. avg)
 

-
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




Coverting seconds on-the-fly to date?

2001-05-30 Thread Michael Bellears

Hi,

Our Radius server reports a users usage as the following -

ACCTSTATUSTYPE  TIME_STAMP
1   991200195
2   991200243
Where ACCTSTATUSTYPE == 1 is starttime and ACCTSTATUSTYPE == 2 is the stop
time

Which with perl, I can use the localtime function to convert 991200243 to
Wed May 30 15:24:03 2001.

What I wanted to be able to do is convert to date on the fly in my mysql
statement, so a user could go to a webpage, enter there username/password
date (eg. 'May') and year (eg. 2001).

Something along the lines of -

$month = 'May'
$year = '2001'

Obviously the following is incorrect with respect to the month+year
statement  ;)

my $sth = $dbh-prepare(SELECT RADUSAGE.USERNAME,COUNT(*) as number,
sum(RADUSAGE.ACCTSESSIONTIME) as ACCTSESSIONTIME,
sum(RADUSAGE.ACCTOUTPUTOCTETS)/1048576 as ACCTOUTPUTOCTETS FROM RADUSAGE
WHERE RADUSAGE.USERNAME = '$user_name' and month(TIME_STAMP) = '$month' AND
year(TIME_STAMP) = '$year' GROUP BY RADUSAGE.USERNAME) or die Couldn't
prepare statement:  . $dbh-errstr;


Hope someone can help.

Regards,
Michael



-
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




Importing data from remote server..

2001-04-19 Thread Michael Bellears

I'm in the process of moving SQL data from one server to another (Linux) -

The tables on the new DBase server are not identical to the old - Is there a
way to import only specified fields data from the old to the new ? 

Thanks in advance,

Regards,
MB

-
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




Calculating multiple instances in MySQL table..

2001-04-16 Thread Michael Bellears

Hi, I have a table with multiple instances of username (Basically a table of
dial-in user's input/output octets).

What I want to do (In Perl), was to select each username (And associated
in/out octets), add them together, and finally print out a total for each
user.

eg.

UsernameInOctetsOutOctets
testuser134838230   1287123474
testuser2   123448  2882779871

I can currently do a query (search) on a particular username, but not search
through
the whole table and give me a grand total on all users.

Any ideas/suggestions are greatly appreciated,

Regards,
MB



-
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