If you are having problems with scrollable cursors and the prepare statement, I've found that you cant set the scrollable option on the connection. The following code (which tries to get the 2nd record):
<?php
$sql = "SELECT * FROM SCHEMA.TABLENAME";
$options = array('cursor' => DB2_SCROLLABLE);
$conn = db2_connect($database, $user, $password,$options);
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
$row = db2_fetch_both($stmt, 2);
$conn = db2_connect($database, $user, $password);
$stmt = db2_prepare($conn, $sql, $options);
$result = db2_execute($stmt);
$row = db2_fetch_both($stmt, 2);
?>
Will result in the following error:
Warning: db2_fetch_both() [function.db2-fetch-both]: Fetch Failure in dbtest.php on line 7
In fact, even if you set the options on both the connection and the prepare your fetch will not work. You must only set that option on the prepare.