douwei3172 2014-12-22 08:24
浏览 27

从PHP创建与Oracle数据库的连接

I am writing a PHP file to read some log files and write the content to Oracle database. I try to create a connection to the database as following.

$conn = oci_pconnect('myservice','oracle123','192.168.0.126:2483/XE');

if (!$conn) {
  $e = oci_error();
  echo trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

Here is my full code.

<!DOCTYPE html>
<html>
<body>

<?php

$conn = oci_pconnect('robiservice','oracle123','192.168.0.26:2483/XE');

if (!$conn) {
 $e = oci_error();
 echo trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} 

$myfile = fopen("14121800_ussd_cdr.file", "r") or die("Unable to open file!");

if ($myfile) {
 while (($line = fgets($myfile)) !== false) {
    echo $line . "</br>";
}
} else {
 // error opening the file.
} 
fclose($myfile);

?>

</body>
</html>

I am running my code in apache server. I put the code into htcocs folder.

But the problem is it gives a blank page. I think I need to install Oracle drivers in the server. But since I am a newbie to this I don't have clear idea about how to do it properly.

Any Suggestions are appreciated.

Thank You

  • 写回答

2条回答 默认 最新

  • drrrdo0802 2014-12-22 08:34
    关注

    You need Oracle Instant Client, Pecl, and oci8 driver. Oracle manual:

    http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?