我写了一个试图搜索我的Oracle数据库的页面。我看不出哪里出错了。尽管我将查询更改为“SELECT * FROM Table WHERE Book_Name =”...“(保证返回结果),但我无法显示任何结果。
$query = "SELECT * FROM Books WHERE Book_Name = 'My Life'";
$dbuser = "username...";
$dbpass = "password...";
$db = "SSID";
$connect = oci_connect($dbuser, $dbpass, $db);
if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}
$stmt = oci_parse($connect, $query);
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
oci_execute($stmt);
?>
some html...
<?php
while(oci_fetch_array($stmt)) {
$fg1 = oci_result($stmt,"BOOK_NAME");
echo ($fg1);
$fg2 = oci_result($stmt,"AUTHOR");
echo ($fg2);
$fg3 = oci_result($stmt,"PRICE");
echo ($fg3);
$fg4 = oci_result($stmt,"IMAGE_LOCATION");
echo ("<br><img src=My Url...".$fg4."><br>");
}
?>
我已经确定Oracle表也是正确的。谢谢你的帮助。
更新: while(oci_fetch_array($stmt)) {
部分之间的任何内容都将无法执行。