-
Using 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
// 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("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
-
Using PHP class to connect to Oracle
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);
}
}
?>
-
PHP and Oracle
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|