How to connect php with Oracle9i database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boss1
    New Member
    • Sep 2007
    • 45

    How to connect php with Oracle9i database?

    i have created a database named:Rezgroup
    and i have already developed some pages but i dont know what is the code to connct Php and oracle.Thats why i can not access the database.

    so far i have come up with the code is:
    [code=vb]<?php
    set conn=Server.Cre ateObject("ADOD B.Connection")
    conn.Provider=" MSDAORA "
    conn.Open "c:/webdata/Rezgroup"
    set rs=Server.Creat eObject("ADODB. recordset")
    rs.Open "nwd_info", conn

    ?>[/code]
    but i m not sure, is that correct or worong?.
    can any body help me.
    Last edited by pbmods; Oct 28 '07, 01:10 PM. Reason: Added CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Boss.

    Please use CODE tags when posting source code:

    &#91;CODE=ph p]
    PHP code goes here.
    &#91;/CODE]

    You posted this in the Articles section. I'll go ahead and move it to the Forum where an Expert will be more likely to find it.

    Note the language that I set on your code tags. The code you posted is not PHP.

    Comment

    • boss1
      New Member
      • Sep 2007
      • 45

      #3
      how to connect php with oracle

      hi,
      i m not getting my solution. Is there any expert who can help me?

      Comment

      • boss1
        New Member
        • Sep 2007
        • 45

        #4
        How to connect php to Oracle9i database?

        How to connect php with Oracle9i database?
        --------------------------------------------------------------------------------

        i have created a database named:Rezgroup
        and i have already developed some pages but i dont know what is the code to connct Php and oracle.Thats why i can not access the database.

        so far i have come up with the code is:

        [code=vb]
        <?php
        set conn=Server.Cre ateObject("ADOD B.Connection")
        conn.Provider=" MSDAORA "
        conn.Open "c:/webdata/Rezgroup"
        set rs=Server.Creat eObject("ADODB. recordset")
        rs.Open "nwd_info", conn

        ?>
        [/code]
        but i m not sure, is that correct or worong?.
        can any body help me.
        Last edited by Atli; Oct 29 '07, 09:14 PM. Reason: Added [code] tags.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Hi.

          That is not PHP code. It kind of looks like VB.NET code encapsulated in PHP tags.

          Check out the Oracle Functions at PHP.net for an example of how to use PHP to connect to Oracle.

          Comment

          • boss1
            New Member
            • Sep 2007
            • 45

            #6
            Connection problem with php and oracle9i database

            i m having a problem with database connectivity.i don't know whats code for connecting oracle9i database with php4.

            is there any body to help me?

            if possible also provide me the code for serial port reader by php.

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Hi.

              You can check out the Oracle Functions at php.net for details on how to connect to oracle databases.

              As for the serial port reader code. We are happy to help you fix any problems you may run into when writing the code yourself, but we will not write it for you.

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Heya, Boss.

                Keep posting duplicate threads, and I'll just keep merging them. You'll never get any help that way.

                Comment

                • post
                  New Member
                  • Sep 2007
                  • 17

                  #9
                  If you are using php to simply connect and select data would require this.
                  [PHP]
                  <?php

                  $conn = oci_connect('us ername', 'password', 'database');
                  if (!$conn) {
                  $e = oci_error();
                  echo htmlentities($e['message']);
                  exit;
                  }

                  $query = 'SELECT * FROM DEPARTMENTS';

                  $stid = oci_parse($conn , $query);
                  if (!$stid) {
                  $e = oci_error($conn );
                  print htmlentities($e['message']);
                  exit;
                  }

                  $r = oci_execute($st id, OCI_DEFAULT);
                  if (!$r) {
                  $e = oci_error($stid );
                  echo htmlentities($e['message']);
                  exit;
                  }
                  print '<table border="1">';
                  while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S)) {
                  print '<tr>';
                  foreach ($row as $item) {
                  print '<td>'.($item?h tmlentities($it em):'&nbsp;').' </td>';
                  }
                  print '</tr>';
                  }
                  print '</table>';
                  oci_close($conn );
                  ?>
                  [/PHP]

                  Not my example got it from php.net :)
                  But look there for future reference first.

                  Comment

                  Working...