Or Die?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

Or Die?

Post 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.
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

yep

Post by james3302 »

Anything pass the connection is not showing. I placed echos in various places to track down where the problem is
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

well

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Or Die?

Post 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");
...
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

or die

Post 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.
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

okay

Post 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.
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

nothing

Post 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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: nothing

Post 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.
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

update

Post 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?
james3302
Forum Commoner
Posts: 53
Joined: Thu Aug 02, 2007 11:11 am

fixed

Post 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.
Post Reply