Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Building PHP classes

517214Jan 5 2008
i have been trying to run this scripts that i got from a text book(Php Oracle web

development) ,but everytime i run it my browser status bar message displays 'Done' but

nothing is displayed.

The scripts are:

<?php

//File: dbConn5.php

class dbConn5 {

private $user;

private $pswd;

private $db;

private $conn;

private $query;

private $row;

private $exec_mode;



public function __construct($user, $pswd, $db, $exec_mode=
OCI_COMMIT_ON_SUCCESS)

{

$this->user = $user;

$this->pswd = $pswd;

$this->db = $db;

$this->exec_mode = $exec_mode;

$this->GetConn();

}

private function GetConn()

{

if(!$this->conn = oci_connect($this->user, $this->pswd, $this->db))

{

$err = oci_error();

trigger_error('Failed to establish a connection: ' . $err['message']);

}

}

public function query($sql)

{

if(!$this->query = oci_parse($this->conn, $sql)) {

$err = oci_error($this->conn);

trigger_error('Failed to execute SQL query: ' . $err['message']);

return false;

}


else if(!oci_execute($this->query, $this->exec_mode)) {

$err = oci_error($this->query);

trigger_error('Failed to execute SQL query: ' . $err['message']);

return false;

}

return true;

}

public function fetch()

{

if($this->row=oci_fetch_assoc($this->query)){

return $this->row;

}

else {

return false;

}

}

}

?>

-------------------------------------------------------------------------------------------------------------------------------------

<?php

//File: hrCred.php

$user="scott";

$pswd="tiger";

$conn="(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = label)

)

)";

?>

----------------------------------------------------------------------------------------------------------------------------------



<html>

<body>

<?php

//File: select.php

include 'dbConn5.php';

include 'hrCred.php';

$db = new dbConn5($user, $pswd, $conn);

$sql="SELECT ENAME, DEPT FROM emp";

if($db->query($sql)){

print 'Employee Names: ' . '
';

while ($row = $db->fetch()) {

print $row['ENAME'] . '&nbsp;';

print $row['DEPT'] . '
';


}

}

?>

</body>

</html>



'Label' is the name of my database/sid while the php files are directly under the 'htdocs'
directory of my webserver.I am using ZendCore.

I am getting upset by this problem,i really need a solution.

Can anyone help????


Thanks
Charles Ajah
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2008
Added on Jan 5 2008
0 comments
1,337 views