473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 10066
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, 535 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 web and I want to access my Oracle database with...
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 in Microsoft Access. Its urgent....
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 please give me solution, thanks...
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 written the following vbScript, that works: ...
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 this, as the dataload will be in millions. hence if...
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. Since Im new to oracle please provide sample code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.