[PHP-DB] // FW Water_foul AW: [PHP-DB] Hi I am new

2004-04-27 Thread Shahed, Raja
This is a very easy and clear tutorial.The basic of PHP/DB you can learn here.

http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html

Best Regards
Raja shahed



-Ursprüngliche Nachricht-
Von: water_foul [mailto:[EMAIL PROTECTED] 
Gesendet: Samstag, 24. April 2004 05:06
An: [EMAIL PROTECTED]
Betreff: [PHP-DB] Hi I am new


I am new to databases and php and I was wondering if any one 
would point me
to a good guide
anything would help :)
thanks in advance,
water_foul

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Session

2004-04-27 Thread Ng Hwee Hwee
Hi,

I have a problem with my session variables. I set them using for e.g., 
$_SESSION[user]=$name;

However, because of weak network links, somehow my $_SESSION variables get unset. Is 
there a way to still keep the session variables even though the network is unstable?? 
i.e. as long as my browser is open, is there a way to still store my session 
variables? by the way, i'm not referring to the session ids, I'm referring to the 
variables that i wanted to session_register().

Thank you.

Regards,
Hwee

Re: [PHP-DB] login script

2004-04-27 Thread Mikael Grön
Here you go:

Table:

ID  Login   PW  Admin
1   admin   abc123  1
2   normal  bcd234  0
3   normal2 cde345  0
PHP:

[BOF]
?php
	if($_POST['login']) {
		$result = mysql_query(select * from users where login = ' . 
$_POST['login'] . ') or die(mysql_error());
		if (mysql_num_rows($result)) {
			$data = mysql_fetch_array($result);
			if ($data[2] == $_POST['pw']) {
$_SESSION['login'] = $data[1];
if ($data[3]) {
	$_SESSION['admin'] = true;
}
header(Location: logged_in.php);
exit;
			} else {
$error = Wrong password;
			}
		} else {
			$error = No such user!;
		}
	}
if ($error) {
	echo span class=\loginError\$error/spanbr /;
}
?
html
head
	titleLogin Script by [EMAIL PROTECTED]/title
style
!--
.error {
	color: #ff;
}
--
/style
head
body bgcolor=#FF
form action=login.php method=post
Login name: input type=text name=login value=?php echo 
$_POST['login'] ? /br /
Password: input type=password name=pw /br /
input type=submit value=Login  /br /
/form
/body
/html
[EOF]

In your admin system, just check for the variable $_SESSION['admin']. 
If true, the user is admin and can do cool stuff.. ;)
I don't care about just having given you a lot of script, since I write 
at least 3 of these per week.
And, make sure there is nothing echoed either by PHP or HTML before the 
login script (or else the redirecting upon successful login won't work)

Regards, Mike

On Apr 27, 2004, at 01:15, andy amol wrote:

hi,
  does anyone have a login script which will take data from the table 
and decide whether the given user is a admin or a normal user.
thanks in advance.

Also if there is some help on session variable I would like to know.

		
-
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs 
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] login script

2004-04-27 Thread Mikael Grön
Err...

As usual I forgot the most important part...
Add
	session_start()

just above the

	if($_POST['login']) {

row, or it won't work at all.. ;)
Or rather, it'll work, but no sessions will be saved.
Mike

On Apr 27, 2004, at 08:48, Mikael Grön wrote:

Here you go:

Table:

ID  Login   PW  Admin
1   admin   abc123  1
2   normal  bcd234  0
3   normal2 cde345  0
PHP:

[BOF]
?php
	if($_POST['login']) {
		$result = mysql_query(select * from users where login = ' . 
$_POST['login'] . ') or die(mysql_error());
		if (mysql_num_rows($result)) {
			$data = mysql_fetch_array($result);
			if ($data[2] == $_POST['pw']) {
$_SESSION['login'] = $data[1];
if ($data[3]) {
	$_SESSION['admin'] = true;
}
header(Location: logged_in.php);
exit;
			} else {
$error = Wrong password;
			}
		} else {
			$error = No such user!;
		}
	}
if ($error) {
	echo span class=\loginError\$error/spanbr /;
}
?
html
head
	titleLogin Script by [EMAIL PROTECTED]/title
style
!--
.error {
	color: #ff;
}
--
/style
head
body bgcolor=#FF
form action=login.php method=post
Login name: input type=text name=login value=?php echo 
$_POST['login'] ? /br /
Password: input type=password name=pw /br /
input type=submit value=Login  /br /
/form
/body
/html
[EOF]

In your admin system, just check for the variable $_SESSION['admin']. 
If true, the user is admin and can do cool stuff.. ;)
I don't care about just having given you a lot of script, since I 
write at least 3 of these per week.
And, make sure there is nothing echoed either by PHP or HTML before 
the login script (or else the redirecting upon successful login won't 
work)

Regards, Mike

On Apr 27, 2004, at 01:15, andy amol wrote:

hi,
  does anyone have a login script which will take data from the table 
and decide whether the given user is a admin or a normal user.
thanks in advance.

Also if there is some help on session variable I would like to know.


-
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Session

2004-04-27 Thread Mikael Grön
Session objects has nothing to do with weak network connections.
If your sessions gets un-set, it's most probably because you forgot the
	session_start();

command in the beginning of some file that is using sessions. Without 
that line, no sessions will be neither stored nor read.

Mike

On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:

Hi,

I have a problem with my session variables. I set them using for e.g., 
$_SESSION[user]=$name;

However, because of weak network links, somehow my $_SESSION variables 
get unset. Is there a way to still keep the session variables even 
though the network is unstable?? i.e. as long as my browser is open, 
is there a way to still store my session variables? by the way, i'm 
not referring to the session ids, I'm referring to the variables that 
i wanted to session_register().

Thank you.

Regards,
Hwee
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Session

2004-04-27 Thread Ng Hwee Hwee
thanx Wendell for your suggestion.

apparently i tried using cookies, but my cookies also get deleted after my
session is disconnected. (?!?!)
i did not set an expiry date to my cookies because i need them to be deleted
when the user closes his browser.
what could i have done wrong??

- Original Message - 
From: Wendell Frohwein [EMAIL PROTECTED]
To: 'Ng Hwee Hwee' [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 3:00 PM
Subject: RE: [PHP-DB] Session


 Im sure you can store the session ID in a cookie. Then this will save
 all your variables.


 I hope this helps.


 Wendell



 -Original Message-
 From: Ng Hwee Hwee [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 26, 2004 11:46 PM
 To: DBList
 Subject: [PHP-DB] Session

 Hi,

 I have a problem with my session variables. I set them using for e.g.,
 $_SESSION[user]=$name;

 However, because of weak network links, somehow my $_SESSION variables
 get unset. Is there a way to still keep the session variables even
 though the network is unstable?? i.e. as long as my browser is open, is
 there a way to still store my session variables? by the way, i'm not
 referring to the session ids, I'm referring to the variables that i
 wanted to session_register().

 Thank you.

 Regards,
 Hwee



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Ng Hwee Hwee
thanx Mike,

i'm sure i have session_start() on all my pages. Why I'm so confident is
because my session gets unset occassionally and not everytime. i cannot find
a pattern and so it is not a consistent problem.. it's so unpredictable!
what could be the problem??

- Original Message - 
From: Mikael Grön [EMAIL PROTECTED]
To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 3:54 PM
Subject: Re: [PHP-DB] Session


 Session objects has nothing to do with weak network connections.
 If your sessions gets un-set, it's most probably because you forgot the

 session_start();

 command in the beginning of some file that is using sessions. Without
 that line, no sessions will be neither stored nor read.

 Mike


 On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:

  Hi,
 
  I have a problem with my session variables. I set them using for e.g.,
  $_SESSION[user]=$name;
 
  However, because of weak network links, somehow my $_SESSION variables
  get unset. Is there a way to still keep the session variables even
  though the network is unstable?? i.e. as long as my browser is open,
  is there a way to still store my session variables? by the way, i'm
  not referring to the session ids, I'm referring to the variables that
  i wanted to session_register().
 
  Thank you.
 
  Regards,
  Hwee

 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Torsten Roehr
Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 thanx Mike,

 i'm sure i have session_start() on all my pages. Why I'm so confident is
 because my session gets unset occassionally and not everytime. i cannot
find
 a pattern and so it is not a consistent problem.. it's so unpredictable!
 what could be the problem??

Take alook at this option:

ini_set('session.gc_maxlifetime', 3600); // 3600 seconds

If you don't set it the standard value is 1440 seconds, then your session
data is deleted based on the garbage probablility. Take a look here:

http://de3.php.net/session

Look out for session.gc_maxlifetime and session.gc_probability.

Regards, Torsten



 - Original Message -
 From: Mikael Grön [EMAIL PROTECTED]
 To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 3:54 PM
 Subject: Re: [PHP-DB] Session


  Session objects has nothing to do with weak network connections.
  If your sessions gets un-set, it's most probably because you forgot the
 
  session_start();
 
  command in the beginning of some file that is using sessions. Without
  that line, no sessions will be neither stored nor read.
 
  Mike
 
 
  On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:
 
   Hi,
  
   I have a problem with my session variables. I set them using for e.g.,
   $_SESSION[user]=$name;
  
   However, because of weak network links, somehow my $_SESSION variables
   get unset. Is there a way to still keep the session variables even
   though the network is unstable?? i.e. as long as my browser is open,
   is there a way to still store my session variables? by the way, i'm
   not referring to the session ids, I'm referring to the variables that
   i wanted to session_register().
  
   Thank you.
  
   Regards,
   Hwee
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Ng Hwee Hwee
Hi Torsten,

That is a wonderful insight!!! :o) thanxxx!

okie, my 'session.gc_maxlifetime' = 1440 and session.gc_probability = 1.

so, should I change it to something like 43,200 (12hours*60mins*60sec)?? for example, 
one person works a maximun of 12 hours a day. But does it mean that by lengthening 
this value, the session will still be kept even if the user closes his browser?? 

Please advice!

looking forward to solving this!!

many thanks,
Hwee


- Original Message - 
From: Torsten Roehr [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 6:07 PM
Subject: Re: [PHP-DB] Session


 Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  thanx Mike,
 
  i'm sure i have session_start() on all my pages. Why I'm so confident is
  because my session gets unset occassionally and not everytime. i cannot
 find
  a pattern and so it is not a consistent problem.. it's so unpredictable!
  what could be the problem??
 
 Take alook at this option:
 
 ini_set('session.gc_maxlifetime', 3600); // 3600 seconds
 
 If you don't set it the standard value is 1440 seconds, then your session
 data is deleted based on the garbage probablility. Take a look here:
 
 http://de3.php.net/session
 
 Look out for session.gc_maxlifetime and session.gc_probability.
 
 Regards, Torsten
 
 
 
  - Original Message -
  From: Mikael Grön [EMAIL PROTECTED]
  To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 3:54 PM
  Subject: Re: [PHP-DB] Session
 
 
   Session objects has nothing to do with weak network connections.
   If your sessions gets un-set, it's most probably because you forgot the
  
   session_start();
  
   command in the beginning of some file that is using sessions. Without
   that line, no sessions will be neither stored nor read.
  
   Mike
  
  
   On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:
  
Hi,
   
I have a problem with my session variables. I set them using for e.g.,
$_SESSION[user]=$name;
   
However, because of weak network links, somehow my $_SESSION variables
get unset. Is there a way to still keep the session variables even
though the network is unstable?? i.e. as long as my browser is open,
is there a way to still store my session variables? by the way, i'm
not referring to the session ids, I'm referring to the variables that
i wanted to session_register().
   
Thank you.
   
Regards,
Hwee


Re: [PHP-DB] Session

2004-04-27 Thread Torsten Roehr
Hi Hwee,

of course you could set it to 43200 seonds if you want. The
session.gc_probability value should stay 1 which means that the session data
is deleted with a probability of 1 percent.

The session life time itself is not critical - the life time of the session
DATA is. Which means you should unset all session data after the desired
period of time. Maybe it's easier for you to use a ready-made package like
PEAR::Auth or PEAR::LiveUser:

http://pear.php.net/package/Auth
http://pear.php.net/package/LiveUser


Hope this helps,

Regards, Torsten



Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi Torsten,

That is a wonderful insight!!! :o) thanxxx!

okie, my 'session.gc_maxlifetime' = 1440 and session.gc_probability = 1.

so, should I change it to something like 43,200 (12hours*60mins*60sec)?? for
example, one person works a maximun of 12 hours a day. But does it mean that
by lengthening this value, the session will still be kept even if the user
closes his browser??

Please advice!

looking forward to solving this!!

many thanks,
Hwee


- Original Message -
From: Torsten Roehr [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 6:07 PM
Subject: Re: [PHP-DB] Session


 Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  thanx Mike,
 
  i'm sure i have session_start() on all my pages. Why I'm so confident is
  because my session gets unset occassionally and not everytime. i cannot
 find
  a pattern and so it is not a consistent problem.. it's so unpredictable!
  what could be the problem??

 Take alook at this option:

 ini_set('session.gc_maxlifetime', 3600); // 3600 seconds

 If you don't set it the standard value is 1440 seconds, then your session
 data is deleted based on the garbage probablility. Take a look here:

 http://de3.php.net/session

 Look out for session.gc_maxlifetime and session.gc_probability.

 Regards, Torsten


 
  - Original Message -
  From: Mikael Grön [EMAIL PROTECTED]
  To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 3:54 PM
  Subject: Re: [PHP-DB] Session
 
 
   Session objects has nothing to do with weak network connections.
   If your sessions gets un-set, it's most probably because you forgot
the
  
   session_start();
  
   command in the beginning of some file that is using sessions. Without
   that line, no sessions will be neither stored nor read.
  
   Mike
  
  
   On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:
  
Hi,
   
I have a problem with my session variables. I set them using for
e.g.,
$_SESSION[user]=$name;
   
However, because of weak network links, somehow my $_SESSION
variables
get unset. Is there a way to still keep the session variables even
though the network is unstable?? i.e. as long as my browser is open,
is there a way to still store my session variables? by the way, i'm
not referring to the session ids, I'm referring to the variables
that
i wanted to session_register().
   
Thank you.
   
Regards,
Hwee

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Ng Hwee Hwee
Hi Torsten,

Thank you! Thank you!

just would like to clarify what do you mean by

The session life time itself is not critical - the life time of the session
 DATA is. Which means you should unset all session data after the desired
 period of time.

does it mean that if I set 'session.gc_maxlifetime' = 43200 and then make
sure my user logoff, where my logoff script unset all the sessions, then I'm
on a safe track? I'm designing an intranet, so I can instruct my staff to
logoff and not just close the browser. Will this be okay? I'm not familar
with PEAR yet, but surely would like to learn more about it in future!!

look forward to your reply!

thanks again,
Hwee

- Original Message - 
From: Torsten Roehr [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 6:48 PM
Subject: Re: [PHP-DB] Session


 Hi Hwee,

 of course you could set it to 43200 seonds if you want. The
 session.gc_probability value should stay 1 which means that the session
data
 is deleted with a probability of 1 percent.

 The session life time itself is not critical - the life time of the
session
 DATA is. Which means you should unset all session data after the desired
 period of time. Maybe it's easier for you to use a ready-made package like
 PEAR::Auth or PEAR::LiveUser:

 http://pear.php.net/package/Auth
 http://pear.php.net/package/LiveUser


 Hope this helps,

 Regards, Torsten


 
 Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi Torsten,

 That is a wonderful insight!!! :o) thanxxx!

 okie, my 'session.gc_maxlifetime' = 1440 and session.gc_probability = 1.

 so, should I change it to something like 43,200 (12hours*60mins*60sec)??
for
 example, one person works a maximun of 12 hours a day. But does it mean
that
 by lengthening this value, the session will still be kept even if the user
 closes his browser??

 Please advice!

 looking forward to solving this!!

 many thanks,
 Hwee


 - Original Message -
 From: Torsten Roehr [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 6:07 PM
 Subject: Re: [PHP-DB] Session


  Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   thanx Mike,
  
   i'm sure i have session_start() on all my pages. Why I'm so confident
is
   because my session gets unset occassionally and not everytime. i
cannot
  find
   a pattern and so it is not a consistent problem.. it's so
unpredictable!
   what could be the problem??
 
  Take alook at this option:
 
  ini_set('session.gc_maxlifetime', 3600); // 3600 seconds
 
  If you don't set it the standard value is 1440 seconds, then your
session
  data is deleted based on the garbage probablility. Take a look here:
 
  http://de3.php.net/session
 
  Look out for session.gc_maxlifetime and session.gc_probability.
 
  Regards, Torsten
 
 
  
   - Original Message -
   From: Mikael Grön [EMAIL PROTECTED]
   To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
   Sent: Tuesday, April 27, 2004 3:54 PM
   Subject: Re: [PHP-DB] Session
  
  
Session objects has nothing to do with weak network connections.
If your sessions gets un-set, it's most probably because you forgot
 the
   
session_start();
   
command in the beginning of some file that is using sessions.
Without
that line, no sessions will be neither stored nor read.
   
Mike
   
   
On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:
   
 Hi,

 I have a problem with my session variables. I set them using for
 e.g.,
 $_SESSION[user]=$name;

 However, because of weak network links, somehow my $_SESSION
 variables
 get unset. Is there a way to still keep the session variables even
 though the network is unstable?? i.e. as long as my browser is
open,
 is there a way to still store my session variables? by the way,
i'm
 not referring to the session ids, I'm referring to the variables
 that
 i wanted to session_register().

 Thank you.

 Regards,
 Hwee

 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Torsten Roehr
Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Torsten,

 Thank you! Thank you!

 just would like to clarify what do you mean by

 The session life time itself is not critical - the life time of the
session
  DATA is. Which means you should unset all session data after the desired
  period of time.

 does it mean that if I set 'session.gc_maxlifetime' = 43200 and then make
 sure my user logoff, where my logoff script unset all the sessions, then
I'm
 on a safe track? I'm designing an intranet, so I can instruct my staff to
 logoff and not just close the browser. Will this be okay? I'm not familar
 with PEAR yet, but surely would like to learn more about it in future!!

If you unset all session data you should be safe, but it's better to REALLY
destroy all session data with session_destroy() - take a look at the manual:
http://de.php.net/session_destroy

This should be called when your users logout. The is the preferred way to
end the session. Your users should not just close the browser window - the
session will still be active then and all session data would still be
available if someone gets hold of the session id. After the logout you
should redirect to the login screen WITHOUT forwarding the session id so
that a new session is started.

I'm not familiar with PEAR::Auth nor PEAR::LiveUser - take a look at it and
decide if it's what you want. I'm using the PEAR::HTTP_Session package to
control the session data and have my own Auth class to check if a user is
logged in, the session is expired and so on.

Regards, Torsten



 look forward to your reply!

 thanks again,
 Hwee

 - Original Message -
 From: Torsten Roehr [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 6:48 PM
 Subject: Re: [PHP-DB] Session


  Hi Hwee,
 
  of course you could set it to 43200 seonds if you want. The
  session.gc_probability value should stay 1 which means that the session
 data
  is deleted with a probability of 1 percent.
 
  The session life time itself is not critical - the life time of the
 session
  DATA is. Which means you should unset all session data after the desired
  period of time. Maybe it's easier for you to use a ready-made package
like
  PEAR::Auth or PEAR::LiveUser:
 
  http://pear.php.net/package/Auth
  http://pear.php.net/package/LiveUser
 
 
  Hope this helps,
 
  Regards, Torsten
 
 
  
  Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
  Hi Torsten,
 
  That is a wonderful insight!!! :o) thanxxx!
 
  okie, my 'session.gc_maxlifetime' = 1440 and session.gc_probability = 1.
 
  so, should I change it to something like 43,200 (12hours*60mins*60sec)??
 for
  example, one person works a maximun of 12 hours a day. But does it mean
 that
  by lengthening this value, the session will still be kept even if the
user
  closes his browser??
 
  Please advice!
 
  looking forward to solving this!!
 
  many thanks,
  Hwee
 
 
  - Original Message -
  From: Torsten Roehr [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 6:07 PM
  Subject: Re: [PHP-DB] Session
 
 
   Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
thanx Mike,
   
i'm sure i have session_start() on all my pages. Why I'm so
confident
 is
because my session gets unset occassionally and not everytime. i
 cannot
   find
a pattern and so it is not a consistent problem.. it's so
 unpredictable!
what could be the problem??
  
   Take alook at this option:
  
   ini_set('session.gc_maxlifetime', 3600); // 3600 seconds
  
   If you don't set it the standard value is 1440 seconds, then your
 session
   data is deleted based on the garbage probablility. Take a look here:
  
   http://de3.php.net/session
  
   Look out for session.gc_maxlifetime and session.gc_probability.
  
   Regards, Torsten
  
  
   
- Original Message -
From: Mikael Grön [EMAIL PROTECTED]
To: Ng Hwee Hwee [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 3:54 PM
Subject: Re: [PHP-DB] Session
   
   
 Session objects has nothing to do with weak network connections.
 If your sessions gets un-set, it's most probably because you
forgot
  the

 session_start();

 command in the beginning of some file that is using sessions.
 Without
 that line, no sessions will be neither stored nor read.

 Mike


 On Apr 27, 2004, at 07:46, Ng Hwee Hwee wrote:

  Hi,
 
  I have a problem with my session variables. I set them using for
  e.g.,
  $_SESSION[user]=$name;
 
  However, because of weak network links, somehow my $_SESSION
  variables
  get unset. Is there a way to still keep the session variables
even
  though the network is unstable?? i.e. as long as my browser is
 open,
  is there a way to still store my session variables? by the way,
 i'm
  not referring to the session ids, I'm referring to the variables
  

Re: [PHP-DB] Session

2004-04-27 Thread John W. Holmes
From: Ng Hwee Hwee [EMAIL PROTECTED]

 okie, my 'session.gc_maxlifetime' = 1440 and session.gc_probability = 1.

 so, should I change it to something like 43,200 (12hours*60mins*60sec)??
 for example, one person works a maximun of 12 hours a day. But does
 it mean that by lengthening this value, the session will still be kept
even
 if the user closes his browser??

Setting your gc_maxlifetime to that means that the server will not delete
the users session data files until they are over 43200 seconds old, meaning
the user hasn't requested a page in over 12 hours.

The session does not exist past the point of closing the browser unless you
increase the lifetime of the session cookie itself. I would recommend you
just leave it at zero, though, meaning it only persists for as long as the
browser window is open. The longer you make the sessions last, the easier it
is for someone to hijack them.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Hans Lellelid
Hi -

John W. Holmes wrote:
The session does not exist past the point of closing the browser unless you
increase the lifetime of the session cookie itself. I would recommend you
just leave it at zero, though, meaning it only persists for as long as the
browser window is open. The longer you make the sessions last, the easier it
is for someone to hijack them.
One point of clarification here.  The *cookie* doesn't exist past the 
point of closing the browser, but the session file (assuming using 
files) will continue to exist until it has been garbage collected or 
until session_destroy() is called.  Also, if you weren't using cookies 
(were passing session id in URL) you could open your browser again and 
navigate back using your history  you'd still be logged in.  That's why 
it's a good idea to always call session_destroy() when a user logs out. 
 That will effectively delete all session data on the server.

Of course, as John mentions, once the user closes the browser the 
in-memory cookie will be deleted and (if you're using only cookies) 
there's no longer any connection between that client computer and the 
session stored on the server.  In that respect the session exists no 
longer, but as mentioned the data will still be there on the server.  If 
someone knows (e.g. hijacker) the session ID, they can revive the 
session by just adding it to the URL.

On that note, here are a few things you might want to consider if you 
want to make sessions more secure:

- use only cookies for sessions. (session.use_only_cookies = 1)  This 
prevents the session ID from *ever* being added to the URL.  URLs get 
logged -- by apache, by proxy servers, by user bookmarks :) -- and if a 
URL contains a session ID then you have that mentioned problem where a 
session can be easily revived after the user closes the browser 
(effectively session hijacking, intentional or not).

- regenerate the session id when a user logs in. simply run 
session_regenerate_id() after the username/password has been verified. 
This goes a long way to prevent session fixation, another type of 
session attack in which an attacker makes a user log in using a fixed 
session id (e.g. by clicking on a link that includes something like 
PHPSESSID=1234); once the user logs in using this fake session id, the 
attacker can use that session id in order to have access to the system 
as whichever user logged in.  (Do a search on session fixation for 
more information on that.)

- keep your gc_maxlifetime as small as possible; that way if a user does 
close their browser their session won't remain active for 12+ hours. 
You might want to consider ways of periodically refreshing the page 
using an iframe or even just a meta refresh... solution.  That will 
address the need to stay logged-in while the browser is open, while also 
allowing you to have a very brief session lifetime.

Hans

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Session

2004-04-27 Thread John W. Holmes
From: Hans Lellelid [EMAIL PROTECTED]

 - keep your gc_maxlifetime as small as possible; that way if a user does
 close their browser their session won't remain active for 12+ hours.
 You might want to consider ways of periodically refreshing the page
 using an iframe or even just a meta refresh... solution.  That will
 address the need to stay logged-in while the browser is open, while also
 allowing you to have a very brief session lifetime.

Excellent points, Hans.

One other thing to add. When a user requests a page and you determine that
their session is not valid (probably because they've been inactive too long
and the garbage collection deleted their session file), start a new session
and store the filename and query string of the request before you redirect
back to the login page. Then, after you validate any login, check for the
existance of a saved page and query string and redirect there instead of
your page page.

The end result is a lot cleaner for the user. Sure, they'll have to log in
again, but they'll be redirected right back to the page they requested,
anyhow. You end up with shorter session files making hijacking harder and
less frustration from the user having to navigate back to wherever they
were.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Torsten Roehr
 On that note, here are a few things you might want to consider if you
 want to make sessions more secure:

 - use only cookies for sessions. (session.use_only_cookies = 1)  This
 prevents the session ID from *ever* being added to the URL.  URLs get
 logged -- by apache, by proxy servers, by user bookmarks :) -- and if a
 URL contains a session ID then you have that mentioned problem where a
 session can be easily revived after the user closes the browser
 (effectively session hijacking, intentional or not).

This might be the way to go for an intranet application, like Hwee is going
to do, but not for a website with a wide audience because you are reliant on
the user's client (browser) accepting cookies. One could log the user's user
agent ident string or his ip address and check those with every page request
for further security.

Anyway, very good pieces of advice. Thanks, Hans!

Regards, Torsten

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Procedures in PHP (plphp RC1 released)

2004-04-27 Thread Joshua D. Drake
Hello,

Anyone running PostgreSQL (or wanting to) can write stored procedures, 
functions (same thing), and triggers in PHP using the new release of plPHP.

plPHP offers complete database access to such features as:

SetOf Functions, Composite Types, Triggers, etc...

plPHP is dual licensed under two BSD style licenses (PostgreSQL and PHP).

This release is considered a release candidate as it is basically 
feature complete.

To download plPHP please visit the Command Prompt, Inc. community
pages here:
http://www.commandprompt.com/entry.lxp?lxpe=294

Sincerely,

Joshua D. Drake

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread John.Bedard
:::Novice Alert:::
 
I've done simple select and insert statements, so I suppose this is the most 
complicated thing I've tried to do. but seems to me it should be pretty easy. But I'm 
a designer by background, not a developer or programmer. I've got everything else I'm 
trying to do working.
 
I'm trying to take the largest value out of one table and update another table. The 
former is a PHPBB table and the latter is a table I created just to store the value of 
the date of the most recent post for use in something else. 
 
UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)
 
It returns Invalid use of group function.
 
I've been looking at the documentation on MySQL.com to no avail. I'm testing my query 
in phpMyAdmin before I try to implement it elsewhere. This is what I'm trying to do, 
any help besides RTFM (been doing that) would be greatly appreciated.
 
Thanks!
 
John

John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission Systems | 
Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 | Fax 406.443.8601 | 
 


[PHP-DB] First letter

2004-04-27 Thread matthew perry
What PHP function returns just the first letter of a string?
- Matt
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Swan, Nicole
Have you tried a nested query?  I think your problem is that you're really using 
information from two different tables.

Maybe:

UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM nuke_phpbb_posts);


--Nicole
---
Nicole Swan
Web Programming Specialist
Carroll College CCIT
Helena, Montana
(406)447-4310


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 4:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Request for help on (My)SQL Statement


:::Novice Alert:::
 
I've done simple select and insert statements, so I suppose this is the most 
complicated thing I've tried to do. but seems to me it should be pretty easy. But I'm 
a designer by background, not a developer or programmer. I've got everything else I'm 
trying to do working.
 
I'm trying to take the largest value out of one table and update another table. The 
former is a PHPBB table and the latter is a table I created just to store the value of 
the date of the most recent post for use in something else. 
 
UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)
 
It returns Invalid use of group function.
 
I've been looking at the documentation on MySQL.com to no avail. I'm testing my query 
in phpMyAdmin before I try to implement it elsewhere. This is what I'm trying to do, 
any help besides RTFM (been doing that) would be greatly appreciated.
 
Thanks!
 
John

John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission Systems | 
Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 | Fax 406.443.8601 | 
 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] First letter

2004-04-27 Thread Daniel Clark
$rest = substr(abcdef, 1, 3); // returns bcd

http://www.phpbuilder.com/manual/function.substr.php


 What PHP function returns just the first letter of a string?
 - Matt

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Micah Stevens

That would be the way to do it except that MySQL doesn't support sub-selects 
until version 4.1, which is in alpha still. 

-Micah

On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
 Have you tried a nested query?  I think your problem is that you're really
 using information from two different tables.

 Maybe:

 UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
 nuke_phpbb_posts);


 --Nicole
 ---
 Nicole Swan
 Web Programming Specialist
 Carroll College CCIT
 Helena, Montana
 (406)447-4310


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 4:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Request for help on (My)SQL Statement

 :::Novice Alert:::

 I've done simple select and insert statements, so I suppose this is the
 most complicated thing I've tried to do. but seems to me it should be
 pretty easy. But I'm a designer by background, not a developer or
 programmer. I've got everything else I'm trying to do working.

 I'm trying to take the largest value out of one table and update another
 table. The former is a PHPBB table and the latter is a table I created just
 to store the value of the date of the most recent post for use in something
 else.

 UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)

 It returns Invalid use of group function.

 I've been looking at the documentation on MySQL.com to no avail. I'm
 testing my query in phpMyAdmin before I try to implement it elsewhere. This
 is what I'm trying to do, any help besides RTFM (been doing that) would
 be greatly appreciated.

 Thanks!

 John

 John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
 Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
 Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread John.Bedard
So you're saying there's no way to do it in this version with a single statement?

Thanks,

John

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 5:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Request for help on (My)SQL Statement



That would be the way to do it except that MySQL doesn't support sub-selects 
until version 4.1, which is in alpha still. 

-Micah

On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
 Have you tried a nested query?  I think your problem is that you're really
 using information from two different tables.

 Maybe:

 UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
 nuke_phpbb_posts);


 --Nicole
 ---
 Nicole Swan
 Web Programming Specialist
 Carroll College CCIT
 Helena, Montana
 (406)447-4310


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 4:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Request for help on (My)SQL Statement

 :::Novice Alert:::

 I've done simple select and insert statements, so I suppose this is the
 most complicated thing I've tried to do. but seems to me it should be
 pretty easy. But I'm a designer by background, not a developer or
 programmer. I've got everything else I'm trying to do working.

 I'm trying to take the largest value out of one table and update another
 table. The former is a PHPBB table and the latter is a table I created just
 to store the value of the date of the most recent post for use in something
 else.

 UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)

 It returns Invalid use of group function.

 I've been looking at the documentation on MySQL.com to no avail. I'm
 testing my query in phpMyAdmin before I try to implement it elsewhere. This
 is what I'm trying to do, any help besides RTFM (been doing that) would
 be greatly appreciated.

 Thanks!

 John

 John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
 Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
 Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Swan, Nicole
You're right, of course, Micah.  I guess I've been using my development server (which 
has MySQL 4.1a) for so long, that I've forgotten. :)

I guess, then, that two queries would need to be used instead.

--Nicole

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 5:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Request for help on (My)SQL Statement



That would be the way to do it except that MySQL doesn't support sub-selects 
until version 4.1, which is in alpha still. 

-Micah

On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
 Have you tried a nested query?  I think your problem is that you're really
 using information from two different tables.

 Maybe:

 UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
 nuke_phpbb_posts);


 --Nicole
 ---
 Nicole Swan
 Web Programming Specialist
 Carroll College CCIT
 Helena, Montana
 (406)447-4310


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 4:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Request for help on (My)SQL Statement

 :::Novice Alert:::

 I've done simple select and insert statements, so I suppose this is the
 most complicated thing I've tried to do. but seems to me it should be
 pretty easy. But I'm a designer by background, not a developer or
 programmer. I've got everything else I'm trying to do working.

 I'm trying to take the largest value out of one table and update another
 table. The former is a PHPBB table and the latter is a table I created just
 to store the value of the date of the most recent post for use in something
 else.

 UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)

 It returns Invalid use of group function.

 I've been looking at the documentation on MySQL.com to no avail. I'm
 testing my query in phpMyAdmin before I try to implement it elsewhere. This
 is what I'm trying to do, any help besides RTFM (been doing that) would
 be greatly appreciated.

 Thanks!

 John

 John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
 Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
 Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread John.Bedard
Okay, I'll go in that direction.

Thanks!

John

-Original Message-
From: Swan, Nicole [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 5:17 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Request for help on (My)SQL Statement


You're right, of course, Micah.  I guess I've been using my development server (which 
has MySQL 4.1a) for so long, that I've forgotten. :)

I guess, then, that two queries would need to be used instead.

--Nicole

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 5:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Request for help on (My)SQL Statement



That would be the way to do it except that MySQL doesn't support sub-selects 
until version 4.1, which is in alpha still. 

-Micah

On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
 Have you tried a nested query?  I think your problem is that you're really
 using information from two different tables.

 Maybe:

 UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
 nuke_phpbb_posts);


 --Nicole
 ---
 Nicole Swan
 Web Programming Specialist
 Carroll College CCIT
 Helena, Montana
 (406)447-4310


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 4:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Request for help on (My)SQL Statement

 :::Novice Alert:::

 I've done simple select and insert statements, so I suppose this is the
 most complicated thing I've tried to do. but seems to me it should be
 pretty easy. But I'm a designer by background, not a developer or
 programmer. I've got everything else I'm trying to do working.

 I'm trying to take the largest value out of one table and update another
 table. The former is a PHPBB table and the latter is a table I created just
 to store the value of the date of the most recent post for use in something
 else.

 UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)

 It returns Invalid use of group function.

 I've been looking at the documentation on MySQL.com to no avail. I'm
 testing my query in phpMyAdmin before I try to implement it elsewhere. This
 is what I'm trying to do, any help besides RTFM (been doing that) would
 be greatly appreciated.

 Thanks!

 John

 John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
 Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
 Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] First letter

2004-04-27 Thread Cornelia Boenigk
Hi Matt

You can teat a string like an Array
$first = $string[0];
$second = $string[1]
and so on.

Regards
Conni

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Micah Stevens
Not with MySQL that I know of, some local guru might have an idea.. 

Why are you storing the data in another table? Usually duplicating data in a 
database is a big signal of flawed design. If you're using it somewhere else, 
just select it from the originating table each time. Unless you're trying to 
do something else that I'm not taking into account.

-Micah


On Tuesday 27 April 2004 04:14 pm, [EMAIL PROTECTED] wrote:
 So you're saying there's no way to do it in this version with a single
 statement?

 Thanks,

 John

 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 5:00 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Request for help on (My)SQL Statement



 That would be the way to do it except that MySQL doesn't support
 sub-selects until version 4.1, which is in alpha still.

 -Micah

 On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
  Have you tried a nested query?  I think your problem is that you're
  really using information from two different tables.
 
  Maybe:
 
  UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
  nuke_phpbb_posts);
 
 
  --Nicole
  ---
  Nicole Swan
  Web Programming Specialist
  Carroll College CCIT
  Helena, Montana
  (406)447-4310
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 4:52 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Request for help on (My)SQL Statement
 
  :::Novice Alert:::
 
  I've done simple select and insert statements, so I suppose this is the
  most complicated thing I've tried to do. but seems to me it should be
  pretty easy. But I'm a designer by background, not a developer or
  programmer. I've got everything else I'm trying to do working.
 
  I'm trying to take the largest value out of one table and update another
  table. The former is a PHPBB table and the latter is a table I created
  just to store the value of the date of the most recent post for use in
  something else.
 
  UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)
 
  It returns Invalid use of group function.
 
  I've been looking at the documentation on MySQL.com to no avail. I'm
  testing my query in phpMyAdmin before I try to implement it elsewhere.
  This is what I'm trying to do, any help besides RTFM (been doing that)
  would be greatly appreciated.
 
  Thanks!
 
  John
 
  John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
  Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
  Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Rachel Rodriguez
 
 UPDATE ngc_polling SET lastrundate =
 max(nuke_phpbb_posts.post_time)
  
 It returns Invalid use of group function.
  

John, you're getting that error message because the
max() function requires a GROUP BY clause.  

Try this:

SELECT max(nuke_phpbb_posts.post_time)
FROM nuke_phpbb_posts
GROUP BY nuke_phpbb_posts.post_time;


=
~Rachel




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread John.Bedard
I'm running a notification script that does an action if the date of the last post is 
greater than the last time the script ran, which is the value stored in the other 
table. The action is to notify the members if there has been a new post in the past 24 
hours. 

The client is trying to generate traffic - the members aren't using the site. She 
figures if they are reminded when there's activity on the site (without just 
forwarding all posts to the members - she doesn't want to turn it into a mailing list 
per se) they'll start using it.

The design may be flawed but I don't know any other way to do it. As long as it serves 
the purpose and isn't a total abomination... :)

Thanks,

John

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 5:30 PM
To: Bedard, John
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Request for help on (My)SQL Statement


Not with MySQL that I know of, some local guru might have an idea.. 

Why are you storing the data in another table? Usually duplicating data in a 
database is a big signal of flawed design. If you're using it somewhere else, 
just select it from the originating table each time. Unless you're trying to 
do something else that I'm not taking into account.

-Micah


On Tuesday 27 April 2004 04:14 pm, [EMAIL PROTECTED] wrote:
 So you're saying there's no way to do it in this version with a single
 statement?

 Thanks,

 John

 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 5:00 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Request for help on (My)SQL Statement



 That would be the way to do it except that MySQL doesn't support
 sub-selects until version 4.1, which is in alpha still.

 -Micah

 On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
  Have you tried a nested query?  I think your problem is that you're
  really using information from two different tables.
 
  Maybe:
 
  UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
  nuke_phpbb_posts);
 
 
  --Nicole
  ---
  Nicole Swan
  Web Programming Specialist
  Carroll College CCIT
  Helena, Montana
  (406)447-4310
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 4:52 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Request for help on (My)SQL Statement
 
  :::Novice Alert:::
 
  I've done simple select and insert statements, so I suppose this is the
  most complicated thing I've tried to do. but seems to me it should be
  pretty easy. But I'm a designer by background, not a developer or
  programmer. I've got everything else I'm trying to do working.
 
  I'm trying to take the largest value out of one table and update another
  table. The former is a PHPBB table and the latter is a table I created
  just to store the value of the date of the most recent post for use in
  something else.
 
  UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)
 
  It returns Invalid use of group function.
 
  I've been looking at the documentation on MySQL.com to no avail. I'm
  testing my query in phpMyAdmin before I try to implement it elsewhere.
  This is what I'm trying to do, any help besides RTFM (been doing that)
  would be greatly appreciated.
 
  Thanks!
 
  John
 
  John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
  Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630 |
  Fax 406.443.8601 |

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Rachel Rodriguez
 
 
 John, you're getting that error message because the
 max() function requires a GROUP BY clause.  
 

Ooops, my bad.  It requires a GROUP BY if you are
pulling from more than one column.

=
~Rachel




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Request for help on (My)SQL Statement

2004-04-27 Thread Micah Stevens

Well then there's no reason to copy the value. Just select from the BB table. 
Just:

$l = mysql_fetch_array(mysql_query(SELECT max(post_time) as latest_post FROM 
nuke_phpbb_posts));
$s = mysql_fetch_array(mysql_query(SELECT max(script_run_date) as 
latest_script from script_data)
if ($l['latest_post']  $s['latest_script']) {
echo NEW POSTS!;
}

Or something of that nature. I've done this in the past by setting a cookie on 
the user's system when they log in so I know the last time they logged in, 
and then you can count how many posts have been made since they were there 
last.. that works pretty good. 

-Micah 




On Tuesday 27 April 2004 05:02 pm, [EMAIL PROTECTED] wrote:
 I'm running a notification script that does an action if the date of the
 last post is greater than the last time the script ran, which is the value
 stored in the other table. The action is to notify the members if there has
 been a new post in the past 24 hours.

 The client is trying to generate traffic - the members aren't using the
 site. She figures if they are reminded when there's activity on the site
 (without just forwarding all posts to the members - she doesn't want to
 turn it into a mailing list per se) they'll start using it.

 The design may be flawed but I don't know any other way to do it. As long
 as it serves the purpose and isn't a total abomination... :)

 Thanks,

 John

 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 27, 2004 5:30 PM
 To: Bedard, John
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Request for help on (My)SQL Statement


 Not with MySQL that I know of, some local guru might have an idea..

 Why are you storing the data in another table? Usually duplicating data in
 a database is a big signal of flawed design. If you're using it somewhere
 else, just select it from the originating table each time. Unless you're
 trying to do something else that I'm not taking into account.

 -Micah

 On Tuesday 27 April 2004 04:14 pm, [EMAIL PROTECTED] wrote:
  So you're saying there's no way to do it in this version with a single
  statement?
 
  Thanks,
 
  John
 
  -Original Message-
  From: Micah Stevens [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, April 27, 2004 5:00 PM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] Request for help on (My)SQL Statement
 
 
 
  That would be the way to do it except that MySQL doesn't support
  sub-selects until version 4.1, which is in alpha still.
 
  -Micah
 
  On Tuesday 27 April 2004 04:05 pm, Swan, Nicole wrote:
   Have you tried a nested query?  I think your problem is that you're
   really using information from two different tables.
  
   Maybe:
  
   UPDATE ngc_polling SET lastrundate = (SELECT max(post_time) FROM
   nuke_phpbb_posts);
  
  
   --Nicole
   ---
   Nicole Swan
   Web Programming Specialist
   Carroll College CCIT
   Helena, Montana
   (406)447-4310
  
  
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, April 27, 2004 4:52 PM
   To: [EMAIL PROTECTED]
   Subject: [PHP-DB] Request for help on (My)SQL Statement
  
   :::Novice Alert:::
  
   I've done simple select and insert statements, so I suppose this is the
   most complicated thing I've tried to do. but seems to me it should be
   pretty easy. But I'm a designer by background, not a developer or
   programmer. I've got everything else I'm trying to do working.
  
   I'm trying to take the largest value out of one table and update
   another table. The former is a PHPBB table and the latter is a table I
   created just to store the value of the date of the most recent post for
   use in something else.
  
   UPDATE ngc_polling SET lastrundate = max(nuke_phpbb_posts.post_time)
  
   It returns Invalid use of group function.
  
   I've been looking at the documentation on MySQL.com to no avail. I'm
   testing my query in phpMyAdmin before I try to implement it elsewhere.
   This is what I'm trying to do, any help besides RTFM (been doing
   that) would be greatly appreciated.
  
   Thanks!
  
   John
  
   John Bedard | Interaction Designer (SWEIII) | Northrop Grumman Mission
   Systems | Helena, Montana, U.S.A. | [EMAIL PROTECTED] | 406.443.8630
   | Fax 406.443.8601 |

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] First letter

2004-04-27 Thread holmes072000
 From: matthew perry [EMAIL PROTECTED]

 What PHP function returns just the first letter of a string?

echo substr($str,0,1);

or

echo $str{0};

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Sukanto Kho
Hi, I have a problem in handling session... so I just reply in this topic.

I have created a site... when user login from one browser ..i set a
session['user']

the problem is that when user open another browser ...he is not login ...he
have to login again...

So that 1 pc may login as 2 or more different user from different browser...

Nicholas Sk2

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Daniel Clark
Depends on the browser.   IE and Netscsape handle opening another window
differently.

 Hi, I have a problem in handling session... so I just reply in this topic.

 I have created a site... when user login from one browser ..i set a
 session['user']

 the problem is that when user open another browser ...he is not login
 ...he
 have to login again...

 So that 1 pc may login as 2 or more different user from different
 browser...

 Nicholas Sk2

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Session

2004-04-27 Thread Marcjon Louwersheimer
Do you mean a new browser window or a new browser? Like using IE first
and then netscape? If it's the latter, it wont be saved. It generates a
new session ID and wont use the same session as the first browser.
-- 
  Marcjon

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Cursor in text box.

2004-04-27 Thread matthew perry
My users complain about everything. 
The most common is Why do I have to move the mouse over to this box 
every time?  Wh!
How do I get the cursor to que into the first input area of my form?

-Matt

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Scrolling drop down menu

2004-04-27 Thread matthew perry
When my users choose an option in the drop down menu, they sometimes 
accidentally change what they have chosen when the move the center 
scrolling button of their mouse. 
I was giving a presentation in front of my company's owner and did this 
myself. 
5 or so index fingers instantly pointed at me saying See you do that 
to!  Wh!
Is there a way to stop a menu from scrolling with the center scrolling 
mouse button?

- Matt

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Cursor in text box.

2004-04-27 Thread John W. Holmes
matthew perry wrote:
My users complain about everything. The most common is Why do I have to 
move the mouse over to this box every time?  Wh!
How do I get the cursor to que into the first input area of my form?
JavaScript, not PHP.

document.yourform.yourtextbox.focus(), I think.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Scrolling drop down menu

2004-04-27 Thread John W. Holmes
matthew perry wrote:

When my users choose an option in the drop down menu, they sometimes 
accidentally change what they have chosen when the move the center 
scrolling button of their mouse. I was giving a presentation in front of 
my company's owner and did this myself. 5 or so index fingers instantly 
pointed at me saying See you do that to!  Wh!
Is there a way to stop a menu from scrolling with the center scrolling 
mouse button?
Your questions have nothing to do with PHP.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Cursor in text box.

2004-04-27 Thread Justin Patrin
John W. Holmes wrote:

matthew perry wrote:

My users complain about everything. The most common is Why do I have 
to move the mouse over to this box every time?  Wh!
How do I get the cursor to que into the first input area of my form?


JavaScript, not PHP.

document.yourform.yourtextbox.focus(), I think.

Here's a more cross-browser way:
document.forms[formName].elements[elementName].focus();
--
paperCrane Justin Patrin
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Scrolling drop down menu

2004-04-27 Thread Justin Patrin
John W. Holmes wrote:

matthew perry wrote:

When my users choose an option in the drop down menu, they sometimes 
accidentally change what they have chosen when the move the center 
scrolling button of their mouse. I was giving a presentation in front 
of my company's owner and did this myself. 5 or so index fingers 
instantly pointed at me saying See you do that to!  Wh!
Is there a way to stop a menu from scrolling with the center scrolling 
mouse button?


Your questions have nothing to do with PHP.

And absolutely nothing to do with DB...

--
paperCrane Justin Patrin
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] scrolling drop down menu

2004-04-27 Thread matthew perry
Then I withdraw the question.
Thank you for your time.
John W. Holmes wrote:

matthew perry wrote:

When my users choose an option in the drop down menu, they sometimes 
accidentally change what they have chosen when the move the center 
scrolling button of their mouse. I was giving a presentation in front 
of my company's owner and did this myself. 5 or so index fingers 
instantly pointed at me saying See you do that to!  Wh!
Is there a way to stop a menu from scrolling with the center 
scrolling mouse button?


Your questions have nothing to do with PHP.

And absolutely nothing to do with DB...






Re: [PHP-DB] Cursor in text box.

2004-04-27 Thread Uzi Klein

- Original Message - 
From: matthew perry [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 28, 2004 5:44 AM
Subject: [PHP-DB] Cursor in text box.


 My users complain about everything. 
 The most common is Why do I have to move the mouse over to this box 
 every time?  Wh!
 How do I get the cursor to que into the first input area of my form?
 
 -Matt

easiest way IMO is :

body onload=document.formname.inputname.focus()

Hope it helps.

 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQL - counting number of instances of a word in a field

2004-04-27 Thread Gavin Amm
Hi guys,
 
I'm trying to find a MySQL function(s) that will allow me to count the
number of words in a field.
 
For eg:
 
[table: pages]
id - title - keywords - body
1 - Home - home, page - This is my home page. p Enjoy your stay.
2 - Feedback - feedback, form, contact - Please enter any feedback or
comments in the form below.brYour feedback will be used to improve our
service.
 
How do I, for example, count the number of instances of a word such as
feedback in say the BODY field?
I'm putting together a search engine  I'd like to 'rank' the results
based on the number of instances of each word found in a few fields.
 
In this example, if they search for the words feedback and improve,
the count would result in the row id, word searched and the number of
instances of that word:
(formatting doesn't matter, it's just to give you an idea)
  id 2: feedback count = 2
  id 2: improve count = 1
 
I can play with the weightings later, just need to figure out the
counting...
 
Thanks guys,
Gav


[PHP-DB] Re: Session

2004-04-27 Thread JeRRy

Hi,

Regarding the recent thread on sessions.

If you want cookies to expire after the user leaves
the sie or closes the browser do not leave the expiry
date emty.  9 times out of 10 the cookie will remain. 
All you need to do is set a date that has passed. 
Like 1st Jan 2000.  Most set it way back to 1980
because some people reset their dates and what not for
Program hijacking etc.  So 1980 is a good limit.  You
can use any date passed and it will expire, any future
date it won't expire until the date has been
reached/passed.

Regarding using $ variables.  I have seen on some
servers you can easily use $the vairable but some
servers don't like the user of $ .  I have never seen
an explaination to why this occours, so thought I'd
mention it.  If the session is unset 9 out of 10 times
the $ may be a problem on your server and you will
need to look at alternative methods.

J

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php