Page 1 of 1

OCI error

Posted: Wed Dec 07, 2011 12:07 pm
by lipun4u
Kindly check the following code...

Code: Select all

<?php
	$conn = oci_connect("hr","hrpassword", "XE");
	if(!$conn)
	{
		$e = oci_error();
		echo $e['message'];
	}
	
	$p1 = 'TCS';
	$stid = oci_parse($conn, "select * from stock_comment where upper(stc_comment) like %:p1%");
	oci_bind_by_name($stid, ':p1', $p1);
	
	oci_execute($stid);
	
	echo "<table border='1'>\n";
	
	while($row = oci_fetch_array($stid,  OCI_ASSOC+OCI_RETURN_NULLS))
	{
		echo "<tr>\n";
		foreach($item as $row)
		{
			echo "<td>" . $item . "</td>\n";
		}
		echo "</tr>\n";
	}
	echo "</table>\n";
		
	
	oci_free_statement($stid);
	oci_close($conn);
?>
when i run the code, the following error comes...


Warning: oci_execute() [function.oci-execute]: ORA-00911: invalid character in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ora2.php on line 13

Warning: oci_fetch_array() [function.oci-fetch-array]: ORA-24374: define not done before fetch or execute and fetch in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ora2.php on line 17


Can somebody tell me what is the error at line 13 ?

Re: OCI error

Posted: Wed Dec 07, 2011 1:30 pm
by mikosiko

Code: Select all

        $stid = oci_parse($conn, "select * from stock_comment where upper(stc_comment) like %:p1%");
Invalid SQL sentence ....

Code: Select all

LIKE '%<variable-here>%'

Re: OCI error

Posted: Wed Dec 07, 2011 1:43 pm
by lipun4u
thanx a lot....