Page 1 of 1

Or Die?

Posted: Mon Oct 01, 2007 2:58 pm
by james3302
Im having problems with some code that someone else wrote, I am wanting to see if it is even connecting to the DB

Here the connection code he has

Code: Select all

$db="(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = computer)(PORT = 1521))
    (CONNECT_DATA = (SID = num))
  )"; 

$connection = OCILogon("user","pass",$db);
how do I put in the or die part. When I view the page it diplays the file up until it connects to the DB. I am trying to rule out everything that i can.

yep

Posted: Mon Oct 01, 2007 3:15 pm
by james3302
Anything pass the connection is not showing. I placed echos in various places to track down where the problem is

well

Posted: Mon Oct 01, 2007 3:29 pm
by james3302
I do not have these extensions in my php.ini file

;extension = php_oci8.dll
;extension = php_oracle.dll

so it says to compile php with

--with-oracle=/path/to/oracle/home/dir
--with-oci8=/path/to/oracle/home/dir

but how do I compile php??? In windows?

Re: Or Die?

Posted: Mon Oct 01, 2007 6:24 pm
by califdon
james3302 wrote:Im having problems with some code that someone else wrote, I am wanting to see if it is even connecting to the DB

Here the connection code he has

Code: Select all

$db="(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = computer)(PORT = 1521))
    (CONNECT_DATA = (SID = num))
  )"; 

$connection = OCILogon("user","pass",$db);
how do I put in the or die part. When I view the page it diplays the file up until it connects to the DB. I am trying to rule out everything that i can.
You probably need to put the "or die" in the function OCILogon(). It needs to go in the mysql_connect(.....) command line, like:

Code: Select all

...
mysql_connect(....) or die("Could not connect");
...

or die

Posted: Tue Oct 02, 2007 7:15 am
by james3302
or die returned nothing. So I am going to try and compile php with the oracle extensions. If I ever figure out how in Windows.

okay

Posted: Tue Oct 02, 2007 7:31 am
by james3302
So I copied over a oci.dll file from the oracle directory to the c:\program files\php directory
renamed it php_oci.dll
and added extension=php_oci.dll in the php.ini file. Still nothing.

nothing

Posted: Wed Oct 03, 2007 7:28 am
by james3302
I re-installed php with the oci extension chosen this time to it added it for me. PHP would not start, I read somewhere that I need to have the Oracle 10.2 client librarys for OCILogin to work so I downloaded them and placed them into my ora92 folder. PHP starts with no errors, but still shows nothing after the OCIlogin. The or Die shows nothing.

Re: nothing

Posted: Thu Oct 04, 2007 10:06 pm
by califdon
james3302 wrote:I re-installed php with the oci extension chosen this time to it added it for me. PHP would not start, I read somewhere that I need to have the Oracle 10.2 client librarys for OCILogin to work so I downloaded them and placed them into my ora92 folder. PHP starts with no errors, but still shows nothing after the OCIlogin. The or Die shows nothing.
Ordinarily, if the "or die(...)" doesn't display the error and halt the execution, then the line that it's in didn't result in an error. That could mean that the error you're trying to trap either occurred earlier in the code, so it never reached that line, or it occurred somewhere after that line.

Edit: ...or your program control logic is such that no attempt was made to execute that line.

update

Posted: Fri Oct 05, 2007 7:50 am
by james3302
I have a If statement

if(!$connection)
echo"no good";
if($connection)
echo "good";

and im getting and result of no good.


The reason I was not getting a result from the or die is because PHP did not recognize the ocilogon function. I finally for the oci8.dll working correctly. Is there anyway to see a more specific error as to why it cannot connect?

fixed

Posted: Tue Oct 09, 2007 8:53 am
by james3302
I have to change the SID to something different(I had to ask someone what it was after they got back from vacation) but now on some long queries Im getting


ORA-12170: TNS:Connect timeout occurredTuesday
when I try and connect to the DB in Ohio(im in GA BTW). Short queries to Ohio are no problem.