472,337 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

connect php to oracle

Hi,
How do we connect a Oracle Remote server using php. Can we pass hostname,port,db,username,password into the oci_connect() function?
As per oci_connect() syntax is seems to be not possible , is there any way to connect remote oracle server?
Thanks
Nov 20 '08 #1
15 9920
r035198x
13,262 8TB
Have a look at the oracle instant client.
Nov 20 '08 #2
Have a look at the oracle instant client.
Yes I am trying through it but not yet become success. If you have any stuff to work with instant client please refer the url.

Thanks
Nov 21 '08 #3
r035198x
13,262 8TB
Did you try
http://www.oracle.com/technology/pub/notes/technote_php_instant.html
Nov 21 '08 #4
Did you try
http://www.oracle.com/technology/pub/notes/technote_php_instant.html
No i have not come across this , i will workout on this and get back to you .
Thank You
Nov 21 '08 #5
Did you try
http://www.oracle.com/technology/pub/notes/technote_php_instant.html
Thank You Very much Now i am able to connect Remote Oracle Server and able to handle data.
Nov 21 '08 #6
r035198x
13,262 8TB
That's good news. Good luck with the rest of it.
Nov 21 '08 #7
Hi,
I have connected my Remote Oracle Server through Oracle Instance Client, every thing was going fine. But now i am facing a serious problem like " I am getting same output in three different queries". Each query is fetching data from different oracle views. I am using three different php files for each query.

Even i have used oci_new_connect () in each php file for establishing a new connection but no use.
I am also using oci_parse(),oci_execute() to create a statement and execute statements.
At the end i am also using oci_free_statement(),oci_close() functions to free the result set as well as close the connection.
Finally i am trying to include three php files in a single php file to display the output and find "same output from three different files is being displayed".

I have tried by best and unable to find where the things are going wrong.
Please have a look at this and suggest me to resolve this problem.
Thank You
Nov 25 '08 #8
Hi,
This is in addition to my previous reply i have noticed one thing while investigating the case again "First Statement's result is being appended to the next statement and First and Second Statement's result being appended to the third statement. So any is there any solution to flush memory to avoid this while executing multiple statement's in php.
Thanks
Nov 25 '08 #9
r035198x
13,262 8TB
Would be very useful if you post the code you are using.
Nov 25 '08 #10
Hi,
I have attached a code.zip file which contains 4 files including one index.php and three files where the script is available.
In my oracle database i have three different views which you can find out in my SQL statement.

Thank You
Attached Files
File Type: zip code.zip (2.4 KB, 531 views)
Nov 25 '08 #11
r035198x
13,262 8TB
Better post the code itself here. Most people don't like downloading unknown zip files. Just post the relevant parts of the code here using code tags.
Nov 25 '08 #12
index.php
Expand|Select|Wrap|Line Numbers
  1. <div id="main">
  2.     <div id="second">
  3.  <p class="yesday">IF YOU FORGOT YESTERDAY</p>
  4. <HR>
  5.  
  6. <marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="4">
  7. <div class="ybday"><?php include 'yesday.php';?></div>
  8. <BR>
  9. </marquee>  
  10.  
  11. <p class="today">JUST TO REMIND YOU TODAY</p>
  12. <HR>
  13. <marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="4">
  14. <div class="bday"><?php include 'today.php';?></div>
  15. <BR>
  16. </marquee> 
  17.  
  18. <p class="tmrow">DONT FORGET TOMORROW</p><HR>
  19. <marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="4">
  20.  <div class="tobday"><?php include 'tmrow.php';?></div><br>
  21. </marquee> 
  22.    </div>
tmrow.php
Expand|Select|Wrap|Line Numbers
  1. <?   
  2. $connm = oci_new_connect('username', 'password', 'mydb');
  3. $error='Unable to Connect DataBase';
  4.  if (!$connm)
  5.     {
  6.          echo $error;
  7.     }
  8. $gapa='No Occasions !';
  9. $birthday='Birthday';
  10. $wedding='Marriage Anniversary';
  11. $gap='::';
  12.  
  13. $stmtm = oci_parse ($connm, "SELECT  NAME ,MARRIAGE,BIRTH FROM SOCIAL_CAL_TOMORROW_EVENTS ORDER BY MARRIAGE,BIRTH " );
  14.  oci_execute ($stmtm);
  15.  
  16. if(oci_num_rows($stmtm)>0) 
  17.     {            
  18.         $display_stringb .= "$gapa";  
  19.     }else
  20.     {
  21.  
  22.     while ($resultm = oci_fetch_array($stmtm))
  23.     {
  24.         if($resultm['BIRTH']=='B')
  25.         {
  26.             $display_stringb .= $birthday;
  27.         }
  28.         if($resultm['MARRIAGE']=='M')
  29.         {
  30.             $display_stringb .= $wedding;
  31.         }
  32.  
  33.  
  34.         $display_stringb .= "$gap"; 
  35.  
  36.         $display_stringb .= " $resultm[NAME] ";
  37.  
  38.         $display_stringb .= "$gap"; 
  39.      }
  40. }
  41. echo "<font color= #0259A9 size=2em face=verdana>" .$display_stringb;
  42. oci_free_statement($stmtm);
  43. oci_close($connm);
  44. ?>
today.php
Expand|Select|Wrap|Line Numbers
  1. <?   
  2. $conn = oci_new_connect('username', 'password', 'mydb');
  3. $error='Unable to Connect DataBase';
  4.  if (!$conn)
  5.     {
  6.          echo $error;
  7.     }
  8. $gapa='No Occasions !';
  9. $birthday='Birthday';
  10. $wedding='Marriage Anniversary';
  11. $gap='::';
  12.  
  13. $stmt = oci_parse ($conn, "SELECT  NAME ,MARRIAGE,BIRTH FROM SOCIAL_CAL_TODAY_EVENTS ORDER BY MARRIAGE,BIRTH " );
  14. oci_execute ($stmt);
  15.  
  16. if(oci_num_rows($stmt)>0) 
  17.     {            
  18.         $display_stringb .= "$gapa";  
  19.     }else
  20.     {
  21.  
  22.     while ($resultt = oci_fetch_array($stmt))
  23.     {
  24.         if($resultt['BIRTH']=='B')
  25.         {
  26.             $display_stringb .= $birthday;
  27.         }
  28.         if($resultt['MARRIAGE']=='M')
  29.         {
  30.             $display_stringb .= $wedding;
  31.         }
  32.  
  33.         $display_stringb .= "$gap"; 
  34.  
  35.         $display_stringb .= " $resultt[NAME] ";
  36.  
  37.         $display_stringb .= "$gap"; 
  38.      }
  39. }
  40. echo "<font color= #0259A9 size=2em face=verdana>" .$display_stringb;
  41. oci_free_statement($stmt);
  42. oci_close($conn);
  43.  ?>
yesday.php
Expand|Select|Wrap|Line Numbers
  1. <?   
  2. $conny = oci_new_connect('username', 'password', 'mydb');
  3. $error='Unable to Connect DataBase';
  4.  if (!$conny)
  5.     {
  6.         echo $error;
  7.     }
  8. $gapa='No Occasions !';
  9. $birthday='Birthday';
  10. $wedding='Marriage Anniversary';
  11. $gap='::';
  12.  
  13. $stmty = oci_parse ($conny, "SELECT NAME,MARRIAGE,BIRTH FROM SOCIAL_CAL_YESTERDAY_EVENTS ORDER BY MARRIAGE,BIRTH " );
  14.  oci_execute ($stmty);
  15.  
  16. if(oci_num_rows($stmty)>0) 
  17.     {            
  18.         $display_stringb .= "$gapa";  
  19.     }else
  20.     {
  21.  
  22.     while ($resulty = oci_fetch_array($stmty))
  23.     {
  24.         if($resulty['BIRTH']=='B')
  25.         {
  26.             $display_stringb .= $birthday;
  27.         }
  28.         if($resulty['MARRIAGE']=='M')
  29.         {
  30.             $display_stringb .= $wedding;
  31.         }
  32.  
  33.  
  34.         $display_stringb .= "$gap"; 
  35.  
  36.         $display_stringb .= " $resulty[NAME] ";
  37.  
  38.         $display_stringb .= "$gap"; 
  39.      }
  40. }
  41. echo "<font color= #0259A9 size=2em face=verdana>" .$display_stringb;
  42. oci_free_statement($stmty);
  43. oci_close($conny);
  44. ?>
Do needful
Thank You
Nov 25 '08 #13
Markus
6,050 Expert 4TB
naveenkongati, as you will see I have formatted the code you posted. It is one of the Forum Guidelines that users use [code] tags when they post code. It makes it easier for our experts to read, and will, therefore, raise the chances of a solution.

If you are unsure how to do this, please read the Posting Guidelines.

Thankyou,

Moderator.
Nov 25 '08 #14
r035198x
13,262 8TB
Those includes that you have all over the place are just doing their job. That's why the results appear to be appended.
Nov 25 '08 #15
Please tell me if any solution is there for this ? Can I go for a Ajax call ?Any other way to flush the statement before executes new statement?
Thank You
Nov 26 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Yanick Quirion | last post by:
Hi all, I'm trying to find a simple code to connect to an Oracle Database (9i) with C under linux. I have a script that read a form from the...
2
by: baumann.Pan | last post by:
Dear all , how can I connect to oracle database in C language under linux? thanks in advance
3
by: youbay2001 | last post by:
plz can any body tell me how to make the connect between oracle developer forms 6i with mysql thank for you ,
1
by: minhnguyen19 | last post by:
I use Oracle 9i release 9.0.1.1 I want to connect Oracle with C# by OCI, but I can't add reference to using OCI.dll? What should I do???
1
by: gobirahul | last post by:
Hi Freinds, please, let me know if u have any idea How Can connect Oracle DB to Microsoft Access???? i have the oracle DB but want get this tables...
4
karan8985
by: karan8985 | last post by:
i can not connect the windows services with oracle. i did check all the privilages of oracle and NTFS permissions also ..but still i cant connect...
2
by: dounax | last post by:
Hello, I want to connect to an Oracle 9.2 database from a web site. - I have created a DSN file, I access the database from Excel - I have...
1
by: sindhujanan | last post by:
hai, anyone plz tell the code to connect oracle using database
3
by: techquest | last post by:
Hi, I want to connect into oracle database and export the table data into a flat file using UNIX shell scripts. I cant use other GUI tools to do...
1
by: kprawin | last post by:
I've developed web applications using php and MySQL. Currently I wish to migrate towards oracle. And I need the steps to connect Oracle10g with PHP....
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.