Time variable in php and sql db

2002-06-22 Thread Claudio Carbone

I have a mysql dbase.
I use a time field to save a number of hours (think about number of
houres spent out of office, or anything else).
A table holds the global values for people and their status, another
table holds every single entry of data, so
john smith 5 hours and 2 minutes outside on 16-06-2002 james dillon 10
hours and 25 minutes outside on 22-06-2002 and so on.
Now i need to update the global values (john smith total hours outside
69:53 for example) according to the single entries.
Globally i've already made the algorithm, my problem is:
when in php i read a single time value (eg 5:02 for john smith) and add
it to the global, it si not calculated in the exact time form.
Is it?
So what can i do?
I can't use a time stamp, because i need only times and greater than 24
houres.
So what?
Thank you
Claudio





-
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




Max in query

2002-06-14 Thread Claudio Carbone

Is there a way to obtain max (or min) value in a query?
Example:
i want to know the last id in mytable table
is there a way to do this query?
something like
select id from mytable where id = max;
or something else?
The one i wrote i tried it but it does not work.
Thank you
Claudio



-
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




Query problem

2002-06-11 Thread Claudio Carbone

Hi all, it's the first time i use this ML and i'm pretty new to php and sql
so please excuse me for every well known thing i say.
I'm trying to make a little login routine.
Here i post my code:
HTML
BODY
?php

if(!empty($_POST['submit'])){
 $query1=select * from admin where User=$user;;
 include (dbdats.txt);
 $link = mysql_connect ( $db_host,  $db_login,  $db_pass);
 if(($link)  (mysql_select_db($database,$link))){
  print(Connection to the server is ok.br);
 }
 else{
  print( Can't connect to the server.br);
  exit;
 }
 $user=$_POST['user'];
 $password=$_POST['password'];
 $query=(mysql_query(select * from admin where user=\$user\,$link));
 if(!empty($query)){
  $dati=mysql_query(select * from admin where (user=\$user\ AND
password=\$password\);,$link);
  if(!empty($dati)){
   print(Authentication ok.br);
   for ($i = mysql_num_rows ($dati) - 1; $i =0; $i--) {
if (!mysql_data_seek ($dati, $i))
 continue;
if(!($row = mysql_fetch_object ($dati)))
 continue;
printf ( Welcome back %s!BR\n, $row-User);
   }
  }
  else
   print(Wrong password.br);
 }
 else
  print(User name b.$user./b not valid.br);
}
else{ ?
form method=POST
Inserire UserIdbr
input type=text size=10 name=user
brInserire Passwordbr
input type=password size=10 name=password
input type=submit name=submit value=Login
/form
?php
}
?
/BODY
/HTML

I cannot understand why whatever USER i type i always am authenticated :(
I've put 2 checks:
user name
and
password.
Neverthless everything i type is ok for this script.
Why?
If i type the same queries from the mysql shell, they work!
Can't understand where the error is.
Hope some one can help me.
Thank you
Claudio


-
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