469,275 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

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 9675
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, 506 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

Post your reply

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

Similar topics

1 post views Thread by Yanick Quirion | last post: by
2 posts views Thread by baumann.Pan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.