尝试从数据库获取数据时出错

发布于 2024-12-05 04:39:04 字数 3110 浏览 0 评论 0原文

这是剧本。我在第 29 行收到错误,这是..

$stmt = OCIParse($connect, $query);

(也比较这个问题 PHP 错误:警告:ociparse() 期望参数 2 为字符串)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?php

/* Set oracle user login and password info */
$dbuser = "sjsrem"; /* your deakin login */
$dbpass = "shaz"; /* your oracle access password */
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);

if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}

$sql = "SELECT * FROM purchase";
$query = OCIParse($connect, $sql);
OCIExecute($query);

/* check the sql statement for errors and if errors report them */
$stmt = OCIParse($connect, $query);
//echo "SQL: $query<br>";
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);?>




<!-- Now we output the data using a table and/or formatted HTML -->




<table>
<?PHP while (OCIFetch($query)) {

   $fg1 = OCIResult ($query , "ID" ) ;   echo("<tr><td>id: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg2 = OCIResult ($query , "FNAME" ) ;   echo("<tr><td>name</td><td>");  echo ($fg2);    echo ("</td> </tr>");
   $fg3 = OCIResult ($query , "LNAME" ) ;   echo("<tr><td>email: </td><td>");    echo ($fg3);   echo ("</td> </tr>");
   $fg4 = OCIResult ($query , "VIN" ) ;   echo("<tr><td>Vin: </td><td>");    echo ($fg4);    echo ("</td> </tr>");
   $fg5 = OCIResult ($query , "EMAIL" ) ;   echo("<tr><td>Email: </td><td>");   echo ($fg5);   echo ("</td> </tr>");
   $fg6 = OCIResult ($query , "UNIT" ) ;   echo("<tr><td>Unit: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg7 = OCIResult ($query , "STREET" ) ;   echo("<tr><td>Street: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg8 = OCIResult ($query , "SUBURB" ) ;   echo("<tr><td>Suburb: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg9 = OCIResult ($query , "PCODE" ) ;   echo("<tr><td>Post Code: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg10 = OCIResult ($query , "CREDIT" ) ;   echo("<tr><td>Credit: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg11 = OCIResult ($query , "HOLDER" ) ;   echo("<tr><td>Holder: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg12 = OCIResult ($query , "EXPIRY" ) ;   echo("<tr><td>Expiry: </td><td>");  echo ($fg1);   echo ("</td> </tr>");


   }  



   ?>
</table>
</body>
</html>

This is the script. I am getting an error on line 29 which is..

$stmt = OCIParse($connect, $query);

(Compare as well this question PHP error: Warning: ociparse() expects parameter 2 to be string)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?php

/* Set oracle user login and password info */
$dbuser = "sjsrem"; /* your deakin login */
$dbpass = "shaz"; /* your oracle access password */
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);

if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}

$sql = "SELECT * FROM purchase";
$query = OCIParse($connect, $sql);
OCIExecute($query);

/* check the sql statement for errors and if errors report them */
$stmt = OCIParse($connect, $query);
//echo "SQL: $query<br>";
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);?>




<!-- Now we output the data using a table and/or formatted HTML -->




<table>
<?PHP while (OCIFetch($query)) {

   $fg1 = OCIResult ($query , "ID" ) ;   echo("<tr><td>id: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg2 = OCIResult ($query , "FNAME" ) ;   echo("<tr><td>name</td><td>");  echo ($fg2);    echo ("</td> </tr>");
   $fg3 = OCIResult ($query , "LNAME" ) ;   echo("<tr><td>email: </td><td>");    echo ($fg3);   echo ("</td> </tr>");
   $fg4 = OCIResult ($query , "VIN" ) ;   echo("<tr><td>Vin: </td><td>");    echo ($fg4);    echo ("</td> </tr>");
   $fg5 = OCIResult ($query , "EMAIL" ) ;   echo("<tr><td>Email: </td><td>");   echo ($fg5);   echo ("</td> </tr>");
   $fg6 = OCIResult ($query , "UNIT" ) ;   echo("<tr><td>Unit: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg7 = OCIResult ($query , "STREET" ) ;   echo("<tr><td>Street: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg8 = OCIResult ($query , "SUBURB" ) ;   echo("<tr><td>Suburb: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg9 = OCIResult ($query , "PCODE" ) ;   echo("<tr><td>Post Code: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg10 = OCIResult ($query , "CREDIT" ) ;   echo("<tr><td>Credit: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg11 = OCIResult ($query , "HOLDER" ) ;   echo("<tr><td>Holder: </td><td>");  echo ($fg1);   echo ("</td> </tr>");
   $fg12 = OCIResult ($query , "EXPIRY" ) ;   echo("<tr><td>Expiry: </td><td>");  echo ($fg1);   echo ("</td> </tr>");


   }  



   ?>
</table>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℡寂寞咖啡 2024-12-12 04:39:04

参数必须是资源,但您正在传递 sql 字符串。在您的代码资源中是$stmt。您需要使用 $stmt 而不是 $query

OCIFetch($stmt)

另外对于 OCIResult 您需要再次使用 OCIResult($stmt) 不是 OCIResult($query)

Parameter must be a resource but you are passing sql string. In your code resource is $stmt. You need to use $stmt instead of $query

OCIFetch($stmt)

Also for OCIResult again you need to use OCIResult($stmt) not OCIResult($query)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文