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: [EMAIL PROTECTED]
USPHARMA Database Site
"Muhammed Mamedov" <[EMAIL PROTECTED]>
10-Sep-2003 18:31
To
[EMAIL PROTECTED]
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
[EMAIL PROTECTED]($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" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have the following problem, please help me. Many thanks.
>
> Script 1:
> <?php
>
> [EMAIL PROTECTED]($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