Home >Backend Development >PHP Tutorial >Sample code for php to connect to oracle database

Sample code for php to connect to oracle database

WBOY
WBOYOriginal
2016-07-25 08:55:361765browse
  1. if ($conn=OCILogon("kai","fjelite","linux"))
  2. { echo "SUCCESS ! Connected to database/n";
  3. }
  4. else
  5. {echo "Failed :-( Could not connect to database/n";}
  6. $stmt = OCIParse($conn,"select tel,AREA from hkh_tel ");
  7. OCIDefineByName($stmt,"TEL",&$TEL);
  8. OCIDefineByName($stmt,"AREA",&$AREA);
  9. OCIExecute($stmt);
  10. while
  11. ( // bbs.it-home.org
  12. OCIFetch($stmt))
  13. {
  14. echo "TEL:". $TEL."/t";
  15. echo "AREA:".$AREA."/n";
  16. }
  17. OCIFreeStatement($stmt);
  18. OCILogoff($conn);
  19. ?>
Copy code

2, plus execution permissions:

  1. chmod 755 /var/www/html/conn_ora.php
Copy code

3, local debugging:

  1. /usr/bin/php /var/www/html/conn_ora.php
Copy code

>>>Articles you may be interested in: A summary of how to connect Access database with php Three ways to connect PHP to access database Example of php ADO component connecting to access database Simple example of php connecting to database Some summary about php connecting to mssql Share a PHP class to connect to sql server PHP connects to mssql database



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn