Oracle-Account-PHP

Document Sample
Oracle-Account-PHP Powered By Docstoc
					               A Note for Oracle Accounts and PHP
                                  Dr. Dan Wang
                       Email: csdwang@comp.polyu.edu.hk

1. How to invoke sqlplus from Unix Workstations:
a) telnet to an Unix-Workstation :
        b5x-178 ~ 188
        u5x-170 ~ 177
b) setup oracle environment :
        source /compsoft/app/oracle/dbms.cshrc
c) invoke the sqlplus:
        sqlplus your_oracle_account@dbms
        For example, if your oracle account is “cs12345”, then you should input: sqlplus
        cs12345@dbms
d) Enter your Oracle account password.

2. How to change oracle password:
a) Invoke sqlplus as show in 1.
b) Use the command “alter” to change your oracle password:
       SQL > alter user your_oracle_account
       > identified by your_ne w_passwd;

   For example, if your account is “cs12345” and you want to change your
   password to be “d1234”, then it should be:
       SQL > alter user cs12345
       > identified by d1234;

3. How to connect to Oracle using PHP:
The Oracle enabled PHP only works on the web-teaching server
"www2.comp.polyu.edu.hk". To test if you can co nnect to Oracle using PHP, you can
input the following into a file:

<?php
$db="dbms";
if ($c=OCILogon("your_oracle_account", "your_passwd", $db)) {
  echo "Successfully connected to Oracle.\n";
  OCILogoff($c);
} else {
  $err = OCIError();
  echo "Oracle Connect Error " . $err[text];
}
?>
In which, you should replace “your_oracle_account” and “your_passwd” with your
oracle account and password. Name the file as “logon.php”. Put it into your
“/public_html” directory on any UNIX workstation and use the command “chmod 755
logon.php” to change its mode as “-rwxr-xr-x”.

Then you can use web browser such as “IE” to see if you can connect to Oracle using
PHP from the web. Input the following link:

http://www2.comp.polyu.edu.hk/~ YOUR_UNIX_ACCOUNT/logon.php

In which, you should replace “YOUR_UNIX_ACCOUNT” with your unix account. If
you can successful connect, then you should see the message:

Successfully connected to Oracle.

NOTE: if your account starts with a digit, e.g., 0991111t, you have to use „“0991111t”‟,
instead of “0991111t” in the OCILogon

(More contents about PHP/Oracle will be covered in the lectures in the second part
of the course)

4. Useful Links for sqlplus and PHP+Oracle
SQL*Plus User's Guide and Reference:
http://lbdwww.epfl.ch/f/teaching/courses/oracle8i/server.815/a66736/toc.htm
http://www.cis.njit.edu/~jason/classes/oraclemanual/conts.html
PHP+Oracle:
Oracle/PHP FAQ:        http://www.orafaq.com/faqphp.htm
PHP/Oracle functions: http://www.php.net/manual/en/ref.oci8.php

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:305
posted:11/17/2010
language:Malay
pages:2