PHP error: Warning: ociparse() parameter 1 to be resource

Miles_To_Go_B4_I_Die picture Miles_To_Go_B4_I_Die · Nov 3, 2012 · Viewed 7.4k times · Source

As there is not ready made function in oracle to validate the Query so created. So I tried below code to check whether the QUERY is valid or not.

if(isset($_POST['btn_Submit_Query']))
            {
                $check_query=$_POST['txtQuery'];
                echo $check_query;
                $valid = false;
                $stmt = oci_parse($DB, $check_query);
                echo "Statement" . $stmt;
                //oci_define_by_name($stmt, 'NUMBER_OF_ROWS', $number_of_rows);
                oci_execute($stmt, OCI_DEFAULT);
                echo oci_num_rows($stmt);
            }

I got following Warnings in the Execution:

Warning: oci_parse() expects parameter 1 to be resource, object given in D:\xampp\htdocs\app\DashBoardSite\Admin\querybuilder.php on line 899
Statement
Warning: oci_execute() expects parameter 1 to be resource, null given in D:\xampp\htdocs\app\DashBoardSite\Admin\querybuilder.php on line 902

Warning: oci_num_rows() expects parameter 1 to be resource, null given in D:\xampp\htdocs\app\DashBoardSite\Admin\querybuilder.php on line 903

Where is my mistake?

Answer

José Esteves Pereira picture José Esteves Pereira · Nov 3, 2012

You must first connect to the database. This connection must a "resource" to variable $DB.