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 code:

<?php
// for Oracle database connection
$DB_HOST = "hosp";
$DB_USER = "your_oracle_account_name";
$DB_PASS = "your_oracle_account_password";

<?

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

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

<?

$sql = "SELECT STAFF_ENNAME, STAFF_ARNAME
FROM HR_STAFF_MAST
ORDER BY STAFF_ARNAME";
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

    Sorry the connect.inc.php file contains the following code

    <?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);
    }
    }
    ?>

    thanks
    hass_79

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

      [man]ociparse[/man]
      resource ociparse ( resource 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.

      So where is your conn?

        Hi

        I tried to add this line of code before the $sql statment but, i'm still getting the same error

        Hosp
        Resource id #5
        SELECT STAFF_ENNAME, STAFF_ARNAME FROM HR_STAFF_MAST ORDER BY STAFF_ARNAME

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

        $connection = OCILogon("scott","tiger","hosp")
        or die("Couldn't logon to database.");

           // create SQL statement
           $sql = "SELECT STAFF_ENNAME, STAFF_ARNAME
                   FROM HR_STAFF_MAST
                   ORDER BY STAFF_ARNAME";

        echo "<br>";
        echo $connection;
        echo "<br>";
        echo $sql;
        echo "<br>";

          Originally posted by hass_79
          Hi

          I tried to add this line of code before the $sql statment but, i'm still getting the same error

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

          [man]ociparse[/man]
          resource ociparse ( resource 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.

          So where is your conn?

            Hi there

            some lines of my code

            include("connect.inc.php");
            $objoracon= new Vconnect();
            $objoracon->start_connect();
            echo "connection is successful";
            $query4=OCIParse($objoracon, "select STAFF_ENNAME from hr_staff_mast");

            I want to use my connection file (connect.inc.php) for establishing connection so I included it and now I’m using this $objoracon as my connection string and in query I used that object for making connection. I'm getting successful connection but, while retrieving values from database I’m getting the following warning:

            Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource on line55

            thanks
            Please advise
            hass_79

              Write a Reply...