RE: [PHP-DB] accessing two databases within one script

2004-10-05 Thread Oscar Rylin
Of course you can

$whatever_db_linkid = mysql_connect($connectiondetails_for_whatever_db);
if(is_resource($whatever_db_linkid)) { mysql_select_db('whatever_db',
$whatever_db_linkid); }

$someother_db_linkid = mysql_connect($connectiondetails_for_someother_db);
if(is_resource($someother_db_linkid)) { mysql_select_db('someother_db',
$someother_db_linkid); }

// work your magic..



mysql_close($whatever_db_linkid);
mysql_close($someother_db_linkid);

-Original Message-
From: Gary Rachel [mailto:[EMAIL PROTECTED] 
Sent: den 5 oktober 2004 04:31
To: [EMAIL PROTECTED]
Subject: [PHP-DB] accessing two databases within one script

I have a page where I need to access two different databases in mysql.  
After accessing the first database I used  mysql_close($connection);
and then code to access the other database.  The first database access 
works fine, the second gives me the following error message:

*Warning*: mysql_query(): Can't connect to local MySQL server through 
socket '/tmp/mysql.sock'

I've tried not using the mysql_close statement.  But that option doesn't 
select the new database, it seems to stay connected to the previous one, 
despite my specifying a new database to access.  Can I not access two 
databases within the same script?

-- 
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] Question on Registration Method

2004-09-26 Thread Oscar Rylin
Usergroups.
Most likely, you're dealing with an application where you'll want to have
different kinds of users (administrators, power users, users).

Just make a usergroup for accounts that haven't been activated yet.
Also, a separate table holding information on how to activate (something
along the lines of userid, tousergroup, activationcode).

/ rylin

-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: den 26 september 2004 13:46
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question on Registration Method

Right now my registration / login system works like
this:

1-User goes to registration page and fills out form
2-User gets to choose username but password is
autogenerated by system
3-System encrypts password in database
4-Password is unencrypted and sent along with username
to registrant's email address
5-If email fails, insertion into registration database
is rolled back.

I have seen (as we all have) various types of reg
methods.  
While I'm okay with mine, not completely satisfied. 
I'd like to change it to the type where like above the
username and password is sent via email, but with the
addition of a link in the email whereby the user must
click on link to be activated.  You probably have
seen this, but to spell it out - even though they have
the user name and password it somehow is not good
enough to login with until this activation takes
place.

Basically I'm drawing a blank on the precise method
for this system.
Couple of thoughts - 
1-Perhaps there is another table that holds all new
registers until they are activated and then transfers
over the record(s) to the main reg table.
2-There is a column in the table that marks someone
registered ?
3-It's just governed by programming code 
4-Combination of database and PHP to make it work.

Alright , obviously I have no clue.
Appreciate some help, guidelines, pointers, etc.

Thank you,
Stuart

-- 
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] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

2003-11-07 Thread Oscar Rylin
Strtotime()
Look it up in the manual :-)

-Original Message-
From: Karen Resplendo [mailto:[EMAIL PROTECTED] 
Sent: den 7 november 2003 19:44
To: [EMAIL PROTECTED]
Subject: [PHP-DB] CONVERT STRING VARIABLES TO DATES, THEN COMPARE (HOW?)

Apache on NT using MS SQL Srvr 2000
PHP 4.03pl1
 
I return these dates into strings and now I want to compare my database date
to see if it is later than today's date. Pretty sure my Expires field is a
string:
 
Here is the Expires field from the SQL:
Convert(varchar, DATEADD(Year,3,DateCertified),101) AS Expires
 
Here is my PHP code trying to compare dates:
 
$today = date(m/d/Y);
 
   If ($today  odbc_result($data,Expires))
{
 echo brbrLicense has expiredbrbr;
}
   Else
{
 echo brbrLicense has not expiredbrbr;
}
 
Sure could use a simple solution to a simple problem that has me simply
confounded.
 
 


-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

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



Re: [PHP-DB] detecting browser close or change of url

2003-07-02 Thread Oscar Rylin
PHP is server-side, not client side.
That said, what you could do is simply make use of window.onunload or 
window.onclose in javascript to bring up a second window/page..
of course, anyone with half a brain and a popup-stopper won't get that 
page :)

--rylin

Jamie Saunders wrote:

Hi,

I'm trying to figure out a way of detecting when a user closes the browser,
or if they leave the site.  If they do this I'd like to change a value in
the database, i.e:
if (browser is closed by user or they leave site)
{
// run php code to update database
}
Any help much appreciated.

 



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


Re: [PHP-DB] detecting browser close or change of url

2003-07-02 Thread Oscar Rylin
You might also want to take a look at PEAR Auth
http://pear.php.net/manual/en/package.authentication.auth.intro.php
--rylin

Hutchins, Richard wrote:

Jamie,

Read through this thread:
http://marc.theaimsgroup.com/?l=php-dbm=104162246227155w=2
Since you are using a login/logout system, you may be able to use some of
the suggestions in here to solve your problem.
Rich

 

-Original Message-
From: Oscar Rylin [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 11:01 AM
To: Jamie Saunders
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] detecting browser close or change of url
PHP is server-side, not client side.
That said, what you could do is simply make use of window.onunload or 
window.onclose in javascript to bring up a second window/page..
of course, anyone with half a brain and a popup-stopper won't 
get that 
page :)

--rylin

Jamie Saunders wrote:

   

Hi,

I'm trying to figure out a way of detecting when a user 
 

closes the browser,
   

or if they leave the site.  If they do this I'd like to 
 

change a value in
   

the database, i.e:

if (browser is closed by user or they leave site)
{
// run php code to update database
}
Any help much appreciated.



 

--
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] Hi, simple question

2003-07-01 Thread Oscar Rylin
see mysql_insert_id($link_identifier)

-- rylin

Patrik Fomin wrote:

Hi,

im adding a post to the database, is there any way to retrive back the ID
for the post that i just created?
the id is auto_increment and primary key.

like
$sql = insert into test (namn, www) values('test', 'test.com');
mysql_query($sql);
$row = mysql_get_post(id);
?
the only way i could think of was to create a tempfield in the database and
each time you post you give the temp field a unique value, like:
$sql = insert into test (namn, www, unique) values('test',
'test.com','25323324');
mysql_query($sql);
$sql = select id from test where unique = '25323324';
$res = mysql_query($sql);
regards
patrick


 



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