Page 1 of 1

Help: Can't get results returned from query

Posted: Thu Jan 16, 2003 2:20 pm
by stoferj
Hi, I'm trying to connect to an Oracle DB from an NT/IIS/PHP server. I'm getting connected but the query isn't returning anything. I get the message that it connected successfully but then it just spins its wheels. Any help appreciated. Here is my test script.

<?PHP

if ($conn_id = odbc_connect("dev", "test", "test")) {
echo("Connection successful!");
$result = odbc_exec($conn_id, "SELECT SYSDATE FROM DUAL");
odbc_fetch_row($result);
$field1 = odbc_result($result, 1);
echo($field1);

odbc_close($conn_id);
} else {
echo("Cannot connect to data source");
}
?>

Posted: Fri Jan 17, 2003 10:41 am
by BDKR
Perhaps the problem is here.

Code: Select all

$result = odbc_exec($conn_id, "SELECT SYSDATE FROM DUAL");
The reason being that you have no idea if the query ran with success or not. Why not check $result and see what is returned. You could also use odbc_num_rows() to find out how many rows were found.

Cheers,
BDKR