Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [Printsite] Need learn UserID in external script

Quote Reply
Re: [Printsite] Need learn UserID in external script In reply to
You still haven't given enough details to understand what you are trying to do.

Quote:
I want to use library GT in the my scripts?
I'm not sure, but I don't think (licence/copyright wise) you are allowed to pull out parts of the GT library to use in your own scripts. Someone from GT will be able to advise you better.


Quote:
To make inquiry to table Sample_Users_Sessions and to receive session_user_id
Try something like -

###assign the UserID from your external script
my $UserID = "$user_id_value";

###set your database details
my @db_connect = ("DBI:mysql:database_name", "user_name", "password");

###connect to the DBMan SQL database
$DBH = DBI->connect (@db_connect) or die ("Content-type: text/html\n\n Could Not Connect");


###do your query
$query = qq!
SELECT session_id
FROM Sample_Users_Sessions
WHERE session_user_id = $UserID
!;
my $sth = $DBH->prepare ($query) or die ("Content-type: text/html\n\n Could Not Prepare");
$sth->execute or die ("Content-type: text/html\n\n Could Not Execute");

###do somthing with what you find
if ($sth->rows) {
#Do something here
$sth->finish;
# Disconnect
$DBH->disconnect();
exit;
}

else {
#do something else
$sth->finish;
# Disconnect
$DBH->disconnect();
}

You need to replace the red parts with your own values.
As I said before, this seems to be a Perl/MySQL question.
Simon.
Subject Author Views Date
Thread Need learn UserID in external script Printsite 4845 Sep 29, 2004, 2:51 PM
Thread Re: [Printsite] Need learn UserID in external script
jai 4611 Sep 29, 2004, 9:57 PM
Thread Re: [jai] Need learn UserID in external script
Printsite 4627 Sep 30, 2004, 4:32 AM
Thread Re: [Printsite] Need learn UserID in external script
jai 4609 Sep 30, 2004, 7:31 AM
Thread Re: [jai] Need learn UserID in external script
Printsite 4616 Sep 30, 2004, 8:41 AM
Thread Re: [Printsite] Need learn UserID in external script
jai 4595 Sep 30, 2004, 4:12 PM
Thread Re: [jai] Need learn UserID in external script
Printsite 4589 Oct 4, 2004, 4:21 AM
Post Re: [Printsite] Need learn UserID in external script
jai 4552 Oct 4, 2004, 4:41 PM