Number pickup with parallel updating?

2002-04-21 Thread Sascha Kettner

Hi!

I have a small problem:

a have a database containing three fields
number, timestamp, used

i allready inserted into the number fileds about 50.000 random and
unique numbers - timestamp and used are empty

With my perl script i have to do the following:
look into the database for the first entry with having timestamp and
used empty
then updating the timestamp field with the actual date.

My script then in addtion presents the number to the customer via
webinterface.

the next time i run the script the same procedure must be repeated, so
finding the first empty entry (empty timestamp field) and then updating
this filed with a timestamp.

How can i realize this with using perl ? Any advice? How to connect to
database using perl i allready know but iam trying to find out how
manage this small problem the most easy way...
Thanks in advance
Sascha 

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




Select with dbi perl??? Help please!

2002-01-06 Thread Sascha Kettner

Hi!

I have the following script to be executed via post from a web-form; the
var. Pin, msisd and knd are given by the form but however, the script is
not working. I always get no results as if there are no matches, but
this isnt right! This is regardless which entries i submit with the
form!
Any ideas to fix the problem?

Thanks a lot in advance
Regards

Sascha Kettner

#!/usr/bin/perl
  
use DBI();
#
# Get form Data #
#

  parse_form;

# Script Variables #

$input{knd} = ;
$input{pin} = ;
$input{msisdn} = ;


# What to do on submit #


dojob;

##
# Lets have a look at the db #
##

sub dojob {

# Now retrieve data from the table.
my $dbh = DBI-connect(DBI:mysql:database=prepaid;host=localhost,
 root, sascha28,
 {'RaiseError' = 1});
my $sth = $dbh-prepare(SELECT * FROM pins WHERE pin LIKE '$input{pin}'
OR msisdn LIKE '$input{msisdn}' OR knd LIKE '$input{knd}');
print EOF;
Content-type: text/html


html
!--# Include Virtual=/blank.html--
head
titleMAKEPINS/title
meta http-equiv=refresh content=10;url=https:/index.html
/head
body
h1 align=centerSuche Ausgeführt/h1hrbrbr
/body
/html

EOF
$sth-execute();
while (my $ref = $sth-fetchrow_hashref()) {
print Eintrag gefunden: pin = $ref-{'pin'}, msisdn =
$ref-{'msisdn'}\n, knd = $ref-{'knd'}\n\n;
  }
$sth-finish();
# Disconnect from the database.
$dbh-disconnect();
exit;
}
##
# Get form data function #
##

sub parse_form {

   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer)  5) {
 $buffer = $ENV{QUERY_STRING};
}
   @pairs = split(//, $buffer);
   foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);

  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;

  $input{$name} = $value;
   }
}

###
# The end #
###


-
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 mysql-unsubscribe-##L=##[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Select with dbi perl??? Help please!

2002-01-06 Thread Sascha Kettner

HI!

Thanks for your Help! I´ve tried this, but when inserting the % now all
my selections seem to be valid or successful, even if there is no match!
What is wrong? My table for testing has the following entries:

Pin: 123456789123   msisdn:+491231234567knd:test
PIN: 123456789012   msisdn:0knd:test

So when i insert into my form the search for test, f.e. i get both
entries as a result, but even when i insert the search for 123456789123
i get both results as before but when you look at my table, you see,
that only one entry should be displayed! So any other ideas?

Regards
Sascha Kettner

 -Ursprüngliche Nachricht-
 Von: Jesse Shy [mailto:[EMAIL PROTECTED]]
 Gesendet: Sonntag, 6. Januar 2002 23:54
 An: [EMAIL PROTECTED]
 Betreff: RE: Select with dbi perl??? Help please!
 
 
 I have found that unless I put a % sign either before, after
 or both, to denote the match part in question, that I don't 
 get anything. Try  this:  LIKE '$input{pin}%'
 
 that should do it. If not, copy the SQL statement from your
 script to the mysql client to test. I wouldn't retypr it, I 
 would copy it so you try exactly what is in your script.
 
 Good luck!
 
 -Original Message-
 From: Sascha Kettner [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, January 06, 2002 4:14 PM
 To: [EMAIL PROTECTED]
 Subject: Select with dbi perl??? Help please!
 
 
 Hi!
 
 I have the following script to be executed via post from a
 web-form; the var. Pin, msisd and knd are given by the form 
 but however, the script is not working. I always get no 
 results as if there are no matches, but this isnt right! This 
 is regardless which entries i submit with the form! Any ideas 
 to fix the problem?
 
 Thanks a lot in advance
 Regards
 
 Sascha Kettner
 
 #!/usr/bin/perl
 
   use DBI();
 #
 # Get form Data #
 #
 
   parse_form;
 
 # Script Variables #
 
 $input{knd} = ;
 $input{pin} = ;
 $input{msisdn} = ;
 
 
 # What to do on submit #
 
 
 dojob;
 
 ##
 # Lets have a look at the db #
 ##
 
 sub dojob {
 
 # Now retrieve data from the table.
 my $dbh = DBI-connect(DBI:mysql:database=prepaid;host=localhost,
  root, sascha28,
  {'RaiseError' = 1});
 my $sth = $dbh-prepare(SELECT * FROM pins WHERE pin LIKE
 '$input{pin}' OR msisdn LIKE '$input{msisdn}' OR knd LIKE 
 '$input{knd}');
 print EOF;
 Content-type: text/html
 
 
 html
 !--# Include Virtual=/blank.html--
 head
 titleMAKEPINS/title
 meta http-equiv=refresh content=10;url=https:/index.html
 /head
 body
 h1 align=centerSuche Ausgeführt/h1hrbrbr
 /body
 /html
 
 EOF
 $sth-execute();
 while (my $ref = $sth-fetchrow_hashref()) {
 print Eintrag gefunden: pin = $ref-{'pin'}, msisdn =
 $ref-{'msisdn'}\n, knd = $ref-{'knd'}\n\n;
   }
 $sth-finish();
 # Disconnect from the database.
 $dbh-disconnect();
 exit;
 }
 ##
 # Get form data function #
 ##
 
 sub parse_form {
 
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer)  5) {
  $buffer = $ENV{QUERY_STRING};
 }
@pairs = split(//, $buffer);
foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
 
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
 
   $input{$name} = $value;
}
 }
 
 ###
 # The end #
 ###
 
 
 -
 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 mysql-unsubscribe-##L=##[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 mysql-unsubscribe-##L=##[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Watchdog für mysql in Perl?

2002-01-04 Thread Sascha Kettner

Hi!

Short question: i want to have a perl watchdog telling me when executed
if my sql-server is running and if anything is allright with it. So if i
get any errormessage i can restart the server by remote. Has someone
done this allready? Any hint?

Thanks again and best regards

Sascha Kettner


-
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




Perl Problem!

2001-12-23 Thread Sascha Kettner

Hi!

I have a proplem using my perl code to write some data into my mysql
database. When running in consolemode anything works fine, but when
executed by the wwwserver the scripts is processed without errors,
except the data is not written into the database! Any idea how to fixit?
Thanks in advance
Sascha

PS: the code

sub generatepins {

open (GETESTET,  /usr/local/httpd/sms/generated.pin);
open (GENERIERT,  ./pinanfrage.dat);
db connect und write
my $dbh =
DBI-connect(DBI:mysql:database=prepaid;host=localhost,
 root, sascha28,
 {'RaiseError' = 1});
while(my $reader = GENERIERT)
{
chomp($reader);
print GETESTET $reader\n;
$dbh-do(INSERT INTO pins (pin, msisdn, value, knd) VALUES
($reader, 'frei', $wert, '$kunde'));
}
# Disconnect from the database.
$dbh-disconnect();
close GENERIERT;
close GETESTET;

}


-
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 mysql-unsubscribe-##L=##[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php