PHP'db2_prepare failed'错误

I'm using PHP with IBMi that uses db2. I have store procedure that in a testProcedure.php code is below:

                // Prepare Stored Procedure call //
                $proc = 'CALL WLKLIB.DSH3518SQ(?,?,?)';
                $stmt = db2_prepare($conn, $proc) or die("db2_prepare failed         " . db2_stmt_error(). " and " .db2_stmt_errormsg());
                db2_bind_param($stmt, 1, 'inCuCode', DB2_PARAM_IN,DB2_CHAR);
                db2_bind_param($stmt, 2, 'inProdCode', DB2_PARAM_IN,DB2_CHAR);
                db2_bind_param($stmt, 3, 'inBuyNum', DB2_PARAM_IN,DB2_CHAR);
                db2_execute($stmt);
                while (db2_fetch_row($stmt)) {
                    $Fld1  = db2_result($stmt, 0);
                    $Fld2 =  db2_result($stmt, 1);
                    $Fld3 =  db2_result($stmt, 2);
                    $Fld4 =  db2_result($stmt, 3);
                    $Fld5 =  db2_result($stmt, 4);
                    $Fld6 =  db2_result($stmt, 5);
                    $Fld7 =  db2_result($stmt, 6);
                    $Fld8 =  db2_result($stmt, 7);
                    $Fld9 =  db2_result($stmt, 8);
                    $Fld10 =  db2_result($stmt, 9);
                    $Fld11 =  db2_result($stmt, 10);
                    $Fld12 =  db2_result($stmt, 11);
                    $Fld13 =  db2_result($stmt, 12);
                    ?>
                            <p><?php echo $Fld1;?> </p>
                            <p><?php echo $Fld2;?> </p>
                            <p><?php echo $Fld3;?> </p>
                            <p><?php echo $Fld4;?> </p>
                            <p><?php echo $Fld5;?> </p>
                            <p><?php echo $Fld6;?> </p>
                            <p><?php echo $Fld7;?> </p>
                            <p><?php echo $Fld8;?> </p>
                            <p><?php echo $Fld9;?> </p>
                            <p><?php echo $Fld10;?> </p>
                            <p><?php echo $Fld11;?> </p>
                            <p><?php echo $Fld12;?> </p>
                            <p><?php echo $Fld13;?> </p>
                      <?php }?> 

When this file is execute it runs fine and displays the data, but when it is incorporated with my other code give an error saying "db2_prepare failed" and its the same code i'm using both places can you please me in solve this. p.s the database connect in reference at the top.