开发者

PHP: getting data from Oracle 10g database

I am using wamp server 2.0 working with PHP and my database is Oracle 10g.

I am new to php and I am try to fetch data from database.

There are two columns in my table. I want show 1 column data. After executing I get only blank page, without data from database (and yes, there is data in my database).

How can I fix this?

<?php
$c = oci_connect("system", "123", "localhost/XE");
if (!$c) {
  echo "Unable to connect: " . var_dump( oci_error() );
  die();
}

$s = oci_parse($c, "select col2 from tab1");
oci_execute($s, OCI_DEFAULT);
while (开发者_运维百科$row =oci_fetch($s)) {
echo $row['name']."<br>";
}

// Commit to save changes...
oci_commit($c);

// Logoff from Oracle...
oci_free_statement($s);
oci_close($c);
?>


oci_fetch copies a result into an internal buffer that you have to access e.g. using oci_result.

BTW: Had you set a higher value for error_reporting and turned on display_errors, then you would have noticed, that you tried to treat a boolean as an array when printing $row['name'].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜