php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36827 oci_connect() is not returning a valid resource....??
Submitted: 2006-03-22 23:04 UTC Modified: 2006-03-23 10:07 UTC
From: jjackson at medai dot com Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jjackson at medai dot com
New email:
PHP Version: OS:

 

 [2006-03-22 23:04 UTC] jjackson at medai dot com
Description:
------------
The PHP documentation has led me to believe that "oci_connect() returns a connection identifier needed for most other OCI calls" (verbatim from the docs). For the sake of simplicity in this example, I just want to connect then close the connection. However, my call to oci_close() doesn't like what oci_connect() returned.....thinking it's a boolean value instead of the "resource" as shown at: http://us2.php.net/manual/en/function.oci-connect.php

I know it's actually talking to the server because it gives me a logon failure when I use an invalid username/password. 

Reproduce code:
---------------
#!/usr/local/bin/php
<?
$conn = oci_connect('username', 'password', '//server:1521/dbname') || die("Could not connect to Oracle database");
var_dump($conn);
oci_close($conn);
?>

Expected result:
----------------
to not get the warning I am seeing.

Actual result:
--------------
bool(true)

Warning: oci_close() expects parameter 1 to be resource, boolean given in /my/problem/script on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-22 23:13 UTC] tony2001@php.net
You must be doing something terribly wrong, because oci_connect() CAN'T return true. It can return either false or valid connection.
And I'm definitely not able to reproduce it.
 [2006-03-23 02:47 UTC] jjackson at medai dot com
for something that "CAN'T" return true, how is my code and results possibly returning true? :-)
 [2006-03-23 05:29 UTC] rasmus@php.net
Because the || operator has higher precedence than the = operator.  You probably want "or die()" there.  That's why bjori pointer you at the operator precedence table.
 [2006-03-23 05:33 UTC] jjackson at medai dot com
thanks. I need to get more sleep. :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC