Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP oci_connect() - returns nothing

Posted on 2012-08-22
15
Medium Priority
?
2,636 Views
Last Modified: 2012-08-27
Hello,

what i want to do is connect to a oracle db via PHP script (look below).


<?php

error_reporting(E_ALL);


$conn = oci_connect('scott', 'scott', 'localhost/orcl.home');


if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

$stid = oci_parse($conn, 'SELECT * FROM table');

echo "<table border='1'>\n";

while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";

?>


I have already added TNS_ADMIN to register to point to a TNS_NAMES file but it has no effect what so ever.

Script returns nothing ... no error or any other value. Even if i type in fake password i get nothing.

Hope someone has an idea how to solve this !

Thank you for reading!
0
Comment
Question by:Caruso_eu
  • 7
  • 4
  • 2
13 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38322694
What entry do you have in your tnsnames.ora file?

If you have an alias called ORCL, try:

$conn = oci_connect('scott', 'scott', 'ORCL');

http://php.net/manual/en/function.oci-connect.php
0
 

Author Comment

by:Caruso_eu
ID: 38323637
@slightwv: Yes i do and already tried that ... doesnt work.  In fact i can change any oci_connect arguments to false data and still script doesnt produce any errors at all.

I wonder how could i get some sort of error output or eve see if oci_connect is actually working.
0
 

Author Comment

by:Caruso_eu
ID: 38324219
Ok i manage to get error message out of it and i am getting:

 Call to undefined function oci_connect()

In my php.ini (i am under windows 7 64 bit) i have lines

[PHP_OCI8_11G]
extension=php_oci8_11g.dll

un-commented. DLLs are in my ...\ext\ foder  but i am stil getting error message.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38324625
Sorry.  I'm an Oracle guy and cannot help with PHP specific issues.

If no other Expert shows up later today you can click the Request attention link above and a Moderator can see if they can locate some Experts for you.
0
 

Author Comment

by:Caruso_eu
ID: 38324637
Ok thank you.
0
 

Author Comment

by:Caruso_eu
ID: 38332250
Alright i think i have dug out the problem ... oci module is not loading for some reason.

I tried with phpinfo() and php.exe -m and OCI modue is nowhere to be found.

I googled my ass off on this one and no solid answer was found anywhere.

I am using windows 7 64bit
Orace client (administrators instalation)  11R2

and PHP instalation 5.3.16.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38332864
Have you installed the Oracle Client libraries?  php_oci8_11g.dll requires them to operate.  If the Oracle install is on your machine, they are installed with it.  If it is not, then you have to download and install them separately.  More Details here: http://www.php.net/manual/en/oci8.requirements.php
0
 

Author Comment

by:Caruso_eu
ID: 38333916
Yes my oracle database is installed on my window system from where i am running php install as well so this is not the issue i think.
0
 

Author Comment

by:Caruso_eu
ID: 38333917
All i want to do is:

connect to oracle using oci_connect or any other function (if there is one) which could do the same.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38334447
When I installed Oracle/XE on this computer, I had to download and install the Oracle Client library separately.  All of the database extensions in PHP require the drivers that go with the database.  The only one that is shipped with PHP is MySQL.  So you have to download and install any others you want to use.  On http://www.php.net/manual/en/oci8.requirements.php , it tells that php_oci8_11g.dll requires one of three different versions of the client libraries.
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 38334457
Also, the OCI driver won't show up in phpinfo() until the proper client library is installed.
0
 

Author Comment

by:Caruso_eu
ID: 38335505
Allright it was indeed the libraries tho i am not sure which and where.

At home where i have my oracle 11g database on local PC oci_connect doesn't work.

I tried today at work where we have 10g on linux server and everything works fine.

Thank you all for your suggestions!
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38335569
You're welcome.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question