[PHP-DB] php sessions

2005-02-15 Thread mel list_php
Hi!
I have a few questions about the sessions in php.
I have a website where users are authentified through a login/password 
stored in a database. Once accepted, I start a session.

- can I "disconnect" an user? I mean I have a logout script, which is called 
when the user wants to logout, but can I log him out myself? I was thinking 
deleting the session files in php/tmp, but I don't have this access (and 
don't think it is a good way). My second idea was logging myself as this 
user (as I know the login/pass), but will this end its session?
I am not recoding the logout in the sql tables, so is there any way for me 
to kno which sessions are still active?

- this lead to my second question, can I limit the number of session per 
user (to 1)? I think it is possible, because I saw on some websites the 
warning "only one active session allowed per user, if you are already logged 
in you will be disconnected" but I don't know how this is managed.

- if my user is logged in (active session) and try to re-log in, will he 
open a new session or will he re-use the already opened one?

I think the global idea behind all this is how to attach a session to an 
user and how to control it.

Thanks for your help!
_
Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
http://toolbar.msn.co.uk/

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


RE: [PHP-DB] Cannot connect to local server

2005-02-15 Thread Denis Gerasimov

Thanks, Miles!

But actually I have PHP 5.0.2 + MySQL 4.1.9 + mysqli + PEAR::DB latest
installed on the server.

I have spent some weeks struggling with connection and charset problems. But
today I finally solved all these issues except one thing that seems to be a
bug of PEAR::DB package.

The problem is that I CAN connect using 

mysqli://user:[EMAIL PROTECTED]/dbname

connection string and CANNOT connect using

mysqli://user:[EMAIL PROTECTED]/dbname

(privileges/passwords ok, don't worry)

In the last case DB still raises the error message saying:

"Can't connect to local MySQL server through socket '' (111)"
(notice '')

Default socket /var/lib/mysql/mysql.sock does exist. Furthermore, I CAN
connect to localhost using mysqli_* functions. But DB package still shows me
errors when connecting to localhost (and all is OK when it is trying to
connect to example.com via TCP/IP).

Dear DB maintainers, should I report a bug?

> 
> 
> New version of MySQL, old PHP? possible password encryption mis-match?
> Check out:
> 
>  http://dev.mysql.com/doc/mysql/en/old-client.html
> 
> Regards - Miles
> 
> At 06:33 AM 2/10/2005, Denis Gerasimov wrote:
> 
> >Hello,
> >
> >I am trying to connect to MySQL using
> >
> >$mysqli = new mysqli("example.com", "user", "pass", "db");
> >
> >And access is ALWAYS denied
> >(I played around changing user name/pass/host - didn't help me at all)
> >
> >The thing is that I CAN connect to the db server using this user name and
> >password with my DB administration tool.
> >
> >Some background
> >1. MySQL and Apache + PHP are running on the same machine.
> >2. The user is allowed to connect from '%' (everywhere)
> >3. Connecting to localhost fails too (saying "cannot connect to
> socket...")
> >
> >What is going on?
> >
> >Best regards, Denis Gerasimov
> >Outsourcing Services Manager,
> >VEKOS, Ltd.
> >www.vekos.ru
> >
> >--
> >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] To login a user without grant on ISP mysql

2005-02-15 Thread moses Woldeselassie
I tested all my php code on localhost.They were working fine using 
(localhost,bm_user, pss), but now I am using mysql on ISP side. in this case 
I don't have any Privileges on the db.

the registration system works fine, but i do have a problem with login.
I am looking for simple example or any help.
kind regards
meberat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] To login a user without grant on ISP mysql

2005-02-15 Thread Bastien Koert
You need an account with at least select privileges to run any query. Are 
you trying to create an account on the mysql for each user? Don't do that. 
Use table based authentication for each user and use whatever default mysql 
account you have to run the queries.

Bastien
From: "moses Woldeselassie" <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] To login  a user without grant on ISP mysql
Date: Tue, 15 Feb 2005 10:44:32 +
I tested all my php code on localhost.They were working fine using 
(localhost,bm_user, pss), but now I am using mysql on ISP side. in this 
case I don't have any Privileges on the db.

the registration system works fine, but i do have a problem with login.
I am looking for simple example or any help.
kind regards
meberat
--
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] referencing external functions

2005-02-15 Thread J. Connolly
Sorry if this is a duplicate. I accidentally sent to the listserve from 
the wrong address.

I am having trouble calling external functions. I am trying to use this 
to clean up the code in the display. I have this as the function.php


function links() {
global $link;
$sql = "select * from jozef_links";
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>
and am trying to use it in this links3.php

but I keep getting the error message
*Warning*: main(1): failed to open stream: No such file or directory in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
*Warning*: main(): Failed opening '1' for inclusion 
(include_path='.;c:\php4\pear') in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*

Can anyone explain what is wrong. Both files are in the same directory 
and and both have the normal permissions set to access.
Thanks,
jzf

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


Re: [PHP-DB] referencing external functions

2005-02-15 Thread Matt M.
> and am trying to use it in this links3.php
> 
>  include('functions.php') or die (mysql_error());
> ?>
> 
> but I keep getting the error message
> *Warning*: main(1): failed to open stream: No such file or directory in
> *C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
> *Warning*: main(): Failed opening '1' for inclusion
> (include_path='.;c:\php4\pear') in
> *C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
> 
> Can anyone explain what is wrong. Both files are in the same directory
> and and both have the normal permissions set to access.

try the absolute path and try require_once() instead of include().

Also "or die (mysql_error());" is not going to get you anything.  That
is the text of the error message from previous MySQL operation.

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



RE: [PHP-DB] referencing external functions

2005-02-15 Thread Bastien Koert
the error tells me that the files are not in the same dir...I have run into 
this one as well and it was always that case.

Your usage is off though...What you need to do is to include the 
functions.php page and then call a particular function..also any error 
handling should be with the function itself

I handle mine a little differentlytry this:

//echo "commnecing connection to local db";
	if (!($conn=mysql_connect($host, $username, $pwd)))  {
	printf("error connecting to DB by user = $username and pwd=$pwd");
	exit;
	}
	$db3=mysql_select_db($dbname,$conn) or die("Unable to connect to local 
database");

	$result = mysql_query($sql) or die ("Can't connect because ". 
mysql_error());

return $result;
}//end function
?>
Then I include the function like this
require("conn.php");
$sql = "select * from table";
$result = conn($sql); //runs the query and passes back the result
if ($result){
//do something here
}
?>
In your case...i changed your code somewhat

function links() {
//global $link;
$sql = "select * from jozef_links";
$link = connect(); //call the connect function to create the link
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>

bastien
From: "J. Connolly" <[EMAIL PROTECTED]>
To: PHP list 
Subject: [PHP-DB] referencing external functions
Date: Tue, 15 Feb 2005 12:45:29 -0500
Sorry if this is a duplicate. I accidentally sent to the listserve from the 
wrong address.

I am having trouble calling external functions. I am trying to use this to 
clean up the code in the display. I have this as the function.php


function links() {
global $link;
$sql = "select * from jozef_links";
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>
and am trying to use it in this links3.php

but I keep getting the error message
*Warning*: main(1): failed to open stream: No such file or directory in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
*Warning*: main(): Failed opening '1' for inclusion 
(include_path='.;c:\php4\pear') in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*

Can anyone explain what is wrong. Both files are in the same directory and 
and both have the normal permissions set to access.
Thanks,
jzf

--
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] php sessions

2005-02-15 Thread Bastien Koert
The only way to be able to track user sessions would be to use a db, for the 
functionality that you want. Move your entire sessoion handling to the db 
(see here for an article on 
this:http://www.phpbuilder.com/columns/ying2602.php3?aid=19 ) You can 
track user ids, session ids, ip addresses etc with a table. Then its a 
simple matter to kill a user session by flagging or deleting the record.

Sessions tracking and limiting can be done in two ways:
1.  use a cookie and check for the existance of this cookie when the user 
attempts to log on
2. store the IP in a session variable

Bastien
From: "mel list_php" <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] php sessions
Date: Tue, 15 Feb 2005 09:49:24 +
Hi!
I have a few questions about the sessions in php.
I have a website where users are authentified through a login/password 
stored in a database. Once accepted, I start a session.

- can I "disconnect" an user? I mean I have a logout script, which is 
called when the user wants to logout, but can I log him out myself? I was 
thinking deleting the session files in php/tmp, but I don't have this 
access (and don't think it is a good way). My second idea was logging 
myself as this user (as I know the login/pass), but will this end its 
session?
I am not recoding the logout in the sql tables, so is there any way for me 
to kno which sessions are still active?

- this lead to my second question, can I limit the number of session per 
user (to 1)? I think it is possible, because I saw on some websites the 
warning "only one active session allowed per user, if you are already 
logged in you will be disconnected" but I don't know how this is managed.

- if my user is logged in (active session) and try to re-log in, will he 
open a new session or will he re-use the already opened one?

I think the global idea behind all this is how to attach a session to an 
user and how to control it.

Thanks for your help!
_
Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
http://toolbar.msn.co.uk/

--
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] referencing external functions

2005-02-15 Thread J. Connolly
Thanks Bastian,
I did not understand that require and include are not considered 
arguments. When i removed the parentheses everything was ok. I was also 
having a problem because my hosting company shut down my database for 
having too many connections...
jzf

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


Re: [PHP-DB] referencing external functions

2005-02-15 Thread Bastien Koert
You can have that happen even with this code. If they limit the 
max_connections, then the only thing you can do is to manage the connections 
the best you can. OPen and close then for the bare minimum time. Create the 
SQL, then open the connection, process it, get the resultback and close the 
link.

bastien
From: "J. Connolly" <[EMAIL PROTECTED]>
To: PHP list 
Subject: Re: [PHP-DB] referencing external functions
Date: Tue, 15 Feb 2005 14:35:21 -0500
Thanks Bastian,
I did not understand that require and include are not considered arguments. 
When i removed the parentheses everything was ok. I was also having a 
problem because my hosting company shut down my database for having too 
many connections...
jzf

--
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] Database visible via mysql CLI but not MOD_PHP with same username

2005-02-15 Thread Elliot Mackenzie
I have encountered a "hidden database" issue with mod_php, apache2 and
mySQL that I have thus far been unable to resolve.  

I am able to connect to the mysql socket using mysql_connect, but then
find that mysql_list_dbs only returns the "test" database.  This
*sounded* like an issue with the SHOW DATABASES privilege until I found
I was able to log in to the same MySQL server *as the same user* with
the provided command-line client (mysql) and SHOW DATABASES would
display all the other databases on this system.

Furthermore, I tried connecting as root, and again found only the "test"
database was visible to PHP.  If I dropped the test database, no
databases were visible to PHP (regardless of how many databases were
visible using SHOW DATABASES).  If I created "test", "tester",
"testing", "hello" etc, then the "test" database would reappear to PHP,
but no other databases were visible.

I also tried to connect PHP to MySQL as a super-user, and encountered
the exact same issue.

Any advice appreciated,
M.

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



Re: [PHP-DB] Database visible via mysql CLI but not MOD_PHP with same username

2005-02-15 Thread Martin Norland
Elliot Mackenzie wrote:
I have encountered a "hidden database" issue with mod_php, apache2 and
mySQL that I have thus far been unable to resolve.  

I am able to connect to the mysql socket using mysql_connect, but then
find that mysql_list_dbs only returns the "test" database.  This
*sounded* like an issue with the SHOW DATABASES privilege until I found
I was able to log in to the same MySQL server *as the same user* with
the provided command-line client (mysql) and SHOW DATABASES would
display all the other databases on this system.
Furthermore, I tried connecting as root, and again found only the "test"
database was visible to PHP.  If I dropped the test database, no
databases were visible to PHP (regardless of how many databases were
visible using SHOW DATABASES).  If I created "test", "tester",
"testing", "hello" etc, then the "test" database would reappear to PHP,
but no other databases were visible.
I also tried to connect PHP to MySQL as a super-user, and encountered
the exact same issue.
Steps to confirm question:
1) Connect using php, drop 'test' database.
2) Confirm php no longer sees 'test' database.
3) Connect using mysql client, confirm test database is missing.
4) -\
	4a) if so, check mysql database to confirm permissions for root include 
'%' databases and not just 'test'.

4b) if not, change php code to connect to correct mysql server.
Apologies that this may not be very useful, but your problem is 
extremely odd - if it's *not* a permissions / database error.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


Re: [PHP-DB] Database visible via mysql CLI but not MOD_PHP withsame username

2005-02-15 Thread Bastien Koert
sounds like a mysql account user permissions problem to me, too
bastien
From: Martin Norland <[EMAIL PROTECTED]>
Reply-To: php-db@lists.php.net
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Database visible via mysql CLI but not MOD_PHP 
withsame username
Date: Tue, 15 Feb 2005 15:59:09 -0600

Elliot Mackenzie wrote:
I have encountered a "hidden database" issue with mod_php, apache2 and
mySQL that I have thus far been unable to resolve.
I am able to connect to the mysql socket using mysql_connect, but then
find that mysql_list_dbs only returns the "test" database.  This
*sounded* like an issue with the SHOW DATABASES privilege until I found
I was able to log in to the same MySQL server *as the same user* with
the provided command-line client (mysql) and SHOW DATABASES would
display all the other databases on this system.
Furthermore, I tried connecting as root, and again found only the "test"
database was visible to PHP.  If I dropped the test database, no
databases were visible to PHP (regardless of how many databases were
visible using SHOW DATABASES).  If I created "test", "tester",
"testing", "hello" etc, then the "test" database would reappear to PHP,
but no other databases were visible.
I also tried to connect PHP to MySQL as a super-user, and encountered
the exact same issue.
Steps to confirm question:
1) Connect using php, drop 'test' database.
2) Confirm php no longer sees 'test' database.
3) Connect using mysql client, confirm test database is missing.
4) -\
	4a) if so, check mysql database to confirm permissions for root include 
'%' databases and not just 'test'.

4b) if not, change php code to connect to correct mysql server.
Apologies that this may not be very useful, but your problem is extremely 
odd - if it's *not* a permissions / database error.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
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] php sessions

2005-02-15 Thread The Disguised Jedi
you could put in a database an action field, and have a function check
the action on every page.  If the action says certain things, like
KILL or REVALIDATE, then have it perform certain actions.  For the
first, I'd output an error page that says something like "Your session
was killed by administrator (Admin ID)."  Or, ask them for their
password before carrying out their request for the latter example.

there are several ways to do this.  It all depends on what your
server's capabilities and resources are (databases and such) and
personal preference.

HTH,

-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02.  Or .01 Pounds, .014 Euros, or $0.025 CAN.  I'm
already internationally compatible!
PHP rocks!
"Knowledge is Power.  Power Corrupts.  Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored.
This message is Certified Virus Free

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