# Database Discussions > Oracle >  Cannot query database..

## nigyel

Hello,

Pardon me if I posted the post in the wrong topic....

I am connected to an oracle database from my php file. I want to query and print out the result. I can successfully connect to the database but cannot get the output. Please help. I am not an expert and the code might be wrong...

My code: 
<?php 
$dbHost = "xxxx";
$dbHostPort="xxxx";
$dbServiceName = "xxxx";
$usr = "xxxx";
$pswd = "xxxx";
$dbConnStr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
            (HOST=".$dbHost.")(PORT=".$dbHostPort."))
            (CONNECT_DATA=(SERVICE_NAME=".$dbServiceName.")))"  ;

if(!$dbConn = oci_connect($usr,$pswd,$dbConnStr)){
$err = oci_error();
trigger_error('Could not establish a connection: ' . $err['message'], E_USER_ERROR);
};

$strSQL = "select message as A from bnb_mobvw_bal where account_number=UPPER('{%1}') and mobile_no='{%phone}'";
$stmt = oci_parse($dbConn,$strSQL);
if ( ! oci_execute($stmt) ){
$err = oci_error($stmt);
trigger_error('Query failed: ' . $err['message'], E_USER_ERROR);
};

while(oci_fetch($stmt)){
   $rslt = oci_result($stmt, 1); print "query returned: ".$stmt."";
}
?>

Thanks a lot,
Son.

----------

