Oracle-Account-PHP by ashrafp

VIEWS: 2,124 PAGES: 2

									               A Note for Oracle Accounts and PHP
                                  Dr. Dan Wang

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
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_new_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
"". To test if you can connect to Oracle using PHP, you can
input the following into a file:

if ($c=OCILogon("your_oracle_account", "your_passwd", $db)) {
  echo "Successfully connected to Oracle.\n";
} 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:

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:
Oracle/PHP FAQ:
PHP/Oracle functions:

To top