tags:

views:

429

answers:

2

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

A: 

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];
  }
}
Mike B
thanks, Edit 2 fixed the problem, another error message come up
monday.c
Make a separate question as this is a completely different problem.
Mike B
A: 

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

Don