oracle oci_parse 错误信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1776391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
oci_parse error message
提问by monday.c
I get this error message, what does it mean and how to fix it?
我收到此错误消息,这是什么意思以及如何解决?
Warning: oci_parse() expects parameter 1 to be resource, null given in /user_auth_fns.php on line 3
警告:oci_parse() 期望参数 1 是资源,在第 3 行的 /user_auth_fns.php 中给出空值
$conn = db_connect();
$result = oci_parse($conn, "select * from user where username='$username' and passwd = sha1('$password')");
if (!$result){
$err = oci_error();
echo "Could not log you in.";
exit;
}
$r = oci_execute($result);
if (!$r) {
$error = oci_error($conn);
echo "Could not log you in." . $error['message'];
exit;
}
function db_connect()
{
$db = "dbms";
if ($c=oci_connect("username", "password", $db)){
echo "Successfully connected to Oracle.\n";
OCILogoff($c);
} else {
$err = OCIError();
echo "Oracle Connect Error " . $err[text];
}
}
Edit 2fixed the problem, another error message, what other compression function(other than SHA1) should use for oracle?
编辑 2修复了问题,另一个错误消息,oracle 应该使用其他哪些压缩函数(SHA1 除外)?
Warning: oci_execute() [function.oci-execute]: ORA-00904: "SHA1": invalid identifier in /user_auth_fns.php on line 10
警告:oci_execute() [function.oci-execute]:ORA-00904:“SHA1”:第 10 行 /user_auth_fns.php 中的标识符无效
回答by Wahid Masud
I don't know what db_connect() is returning. Maybe it is just creating a connection by its own. Try this:
我不知道 db_connect() 返回什么。也许它只是自己创建了一个连接。尝试这个:
$conn = oci_connect("userName","password","hostName");
fill up the useName & password & hostName here. if you are having problem with hostName then try to put the whole connection string there. example:
在这里填写 useName & password & hostName。如果您在使用 hostName 时遇到问题,请尝试将整个连接字符串放在那里。例子:
$conn = oci_connect('userName', 'password', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = )) (CONNECT_DATA = (SERVICE_NAME = ) (SID = )))');
then you can create a query like
然后你可以创建一个查询
$query="....";
then you can parse like this:
然后你可以这样解析:
$result = oci_parse($conn, $query);
if you succeed in querying then $result holds Boolean value 'true'.
如果您成功查询,则 $result 保存布尔值“true”。
回答by Mike B
Your $conn
variable is null. How do you instantiate that?
您的$conn
变量为空。你如何实例化它?
Edit
编辑
You instantiate $conn
from db_connect()
, which is not part of the standard PHP library so I can not tell you what's wrong with it other than it's returning null.
您实例化$conn
from db_connect()
,它不是标准 PHP 库的一部分,因此除了返回 null 之外,我无法告诉您它有什么问题。
Edit 2
编辑 2
You're db_connect()
doesn't return anything. Additionally, you close the connection immediately after opening it. Try this:
你db_connect()
不返回任何东西。此外,您在打开连接后立即关闭它。尝试这个:
function db_connect()
{
$db = "dbms";
if ($c=oci_connect("username", "password", $db)){
echo "Successfully connected to Oracle.\n";
//OCILogoff($c); // You probably don't want to close the connection here
return $c;
} else {
$err = OCIError();
echo "Oracle Connect Error " . $err[text];
}
}
回答by Don
It means that $conn has no value, it is null. What did you want to have in $conn? Go back and check that.
这意味着 $conn 没有价值,它是空的。你想在 $conn 里有什么?回去检查一下。