Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    3

    Unhappy Unanswered: How to use PHP class to connect to oracle

    Hi there,
    I have created a file called test.php In this
    file I included a different file called connect.inc which contains the following

    <?php
    class Connect{
    var $ocon;

    function start_connectoracle() {
    $this->ocon=ocilogon($DB_USER,$DB_PASS ,$DB_HOST )
    or OCIError("ERROR IN ORACLE CONNECTION");
    }

    function getocon(){
    return ($this->ocon);
    }
    function close_connectoracle(){
    ocilogoff($this->ocon);
    }
    }
    ?>

    the test.php contains the following cod:
    <?php

    include("connect.inc.php");
    ?>

    <?

    $sql = "SELECT STAFF_ENNAME, STAFF_ARNAME
    FROM HR_STAFF_MAST";
    echo "<br>";
    echo $sql;
    echo "<br>";

    // parse SQL statement
    $sql_statement = OCIParse($sql)
    or die("Couldn't parse statement.");
    echo $sql_statement;
    // execute SQL query
    @OCIExecute($sql_statement)
    or die("Couldn't execute statement.");

    // get number of columns for use later
    $num_columns = OCINumCols($sql_statement);
    echo "<br>";
    echo $num_columns;

    ?>

    but, i'm getting the following error:

    Warning: Wrong parameter count for ociparse() in c:\apache\htdocs\oraconn\test1.php on line 80
    Couldn't parse statement.

    My question is how to use PHP class to connect to oracle.

    please advise
    thanks
    hass_79

  2. #2
    Join Date
    Mar 2004
    Posts
    17
    You are missing one parameter in the call to OCIParse:


    OCIParse
    (PHP 3>= 3.0.4, PHP 4 )

    OCIParse -- Parse a query and return a statement
    Description
    int OCIParse ( int conn, string query)


    OCIParse() parses the query using conn. It returns the statement identity if the query is valid, FALSE if not. The query can be any valid SQL statement or PL/SQL block.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •