开发者

oci_parse error message

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

$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 2 fixed the problem, another error message, what other compression function(other than SHA1) should use for oracle?

Warning: oci_execute() [function.oci-execute]: ORA-00904: "SHA1": invalid identifier in /user_auth_fns.php on line 10


I don't know what db_connect() is returning. Maybe it is just creating a connection by its own. Try this:

 $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:

$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'.


Your $conn variable is null. How do you instantiate that?

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.

Edit 2

You're db_connect() doesn't return anything. Additionally, you close the connection immediately after opening it. Try this:

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];
  }
}


It means that $conn has no value, it is null. What did you want to have in $conn? Go back and check that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜