Re: Re: PHP Oracle connection across page.
| From: | roy dot a dot jones at gsk dot com | Date: | Wed, 10 Sep 2003 13:21:30 +0000 |
| Subject: | Re: Re: PHP Oracle connection across page. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30444@lists.php.net to get a copy of this message | ||
Here is how I do it ...
[REF PHP PAGE]
<?php
$conn=include("conn.php");
?>
..... HTMl CODE HERE .....
<?php
$qry="SELECT lower(instance) instance FROM all_databases ORDER BY
instance";
$cursor=ora_open($conn);
ora_parse($cursor,$qry,0);
ora_exec($cursor);
while(ora_fetch($cursor)){
$instance=ora_getcolumn($cursor,0);
echo "<option value =
\"index.php?tns=".$instance."\">".$instance."\n";
}
?>
..... HTMl CODE HERE .....
[conn.php]
<?php
if ($conn=ora_logon($username."@".$tns_alias,$password)) {
$qry="select to_char(sysdate, 'Month DD, YYYY HH:MI AM')
\"SYSDATE\" from dual";
$cursor=ora_open($conn);
ora_parse($cursor,$qry,0);
ora_exec($cursor);
while(ora_fetch($cursor)){
$sysdate=ora_getcolumn($cursor,0);
}
ora_close($cursor);
return $conn;
}
else {
echo "Unable to connect to " .$_GET["tns"];
return -1;
};
?>
----------------------------------------------------------------------
Hope that helps ...
Roy A. Jones
US Pharma Database Administration
GlaxoSmithKline Inc. US Pharma IT, Shared Services
External: (919) 483-0266
Internal: 703-0266
Fax: (919) 315-6842
Office: RC2 - 2005
Email: roy.a.jones@gsk.com
USPHARMA Database Site
"Muhammed Mamedov" <mm@ytm.com.tr>
10-Sep-2003 18:31
To
php-db@lists.php.net
cc
Subject
[PHP-DB] Re: PHP Oracle connection across page.
eventhough I've never used Oracle with PHP here is my suggestion:
create a file that will have your DB connection strings and include it in
every PHP file which uses Oracle connection.
EXAMPLE:
------------------------
[dbCon.php] file
$o_connection=@OCIlogon($o_conn_vars["username"],
$o_conn_vars["password"],
$o_conn_vars["db"]);
[myPhpFile.php]
include_once("dbCon.php");
//Write youe queries now.
--
Muhammed Mamedov
Software Engineer
YTM.com.tr
"Syho" <syho@hkuspace.hku.hk> wrote in message
news:20030906030032.2355.qmail@pb1.pair.com...
> I have the following problem, please help me. Many thanks.
>
> Script 1:
> <?php
>
> $o_connection=@OCIlogon($o_conn_vars["username"],
$o_conn_vars["password"],
> $o_conn_vars["db"]);
>
> //Parse sql statement
> //Execute sql statement.
> ..
> ...
>
> require('2.inc');
>
> ?>
>
____________________________________________________________________________
> ___________
>
> 2.inc:
>
> // This script will switch the brower to script2.php
>
> <html>
>
> <form name="s_form" action="script2.php" method ="POST">
>
>
> </html>
>
>
____________________________________________________________________________
> ____________
>
> script2.php:
>
>
> <?php
>
> My problem is, how to get back the Oracle database connection in this
> script? Please advise.
>
> ?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php