Solved

Warning: expects parameter 1 to be resource

Posted on 2013-12-12
5
1,470 Views
Last Modified: 2016-09-27
Trying to get the ID value of a database entry name and assign to a variable

getting :

Warning: oci_fetch_array() expects parameter 1 to be resource, string given in C:\wamp\www\...  on line 6



$build_stmt = "SELECT ID FROM building where build = '" . $_POST["txtBuilding"] . "'";
echo $build_stmt . '<br>';  			// debug line
$statement = OCIParse($conn, $build_stmt);

if(OCIExecute($statement)){	
	while (($row = oci_fetch_array($build_stmt))) {   //  <--- ERROR LINE
		$building = $row->ID ;
		echo $building . "<br>";		// debug line
	}
}

Open in new window



what am I doing wrong here...
0
Comment
Question by:selhamwy
5 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 125 total points
ID: 39715766
while (($row = oci_fetch_array($statement))) {
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 125 total points
ID: 39715879
Looks like @jacko72 is right.  In addition, the current syntax for OCIExecute is 'oci_execute' and there are examples on this page:
http://www.php.net/manual/en/function.oci-execute.php
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39716510
@selhamwy:  You're still in the deep end and you're floundering because you're relying on some terrible examples.  Suggest you put this project aside and give yourself some time to learn the basics.  Start here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

All of the PHP functions are documented online so they can be right at your fingertips!  But you have to use the web site and read the documentation.  Most, if not all, PHP functions are well-documented.  The man page tells you what kind of input the function requires and what kinds of outputs it can create.  Example:
http://www.php.net/manual/en/function.oci-fetch-array.php

PHP is an evolving language.  Some of the code you're using (code that you have copied from the very, very bad example site that I warned you about) has been officially deprecated.  You can usually find this if you read the online man page.  For example, see the large red warning box in the online description of this function:
http://www.php.net/manual/en/function.ociexecute.php
0
 

Author Closing Comment

by:selhamwy
ID: 39717205
Thanks for the solution and the heads up everyone.

I have went through my code and replaced all Deprecated syntax with current.
0
 

Expert Comment

by:madhura gimhan
ID: 41817299
$conn = oci_connect('ORACLE','ORACLE','//localhost:1521/orcl');

$or_sql = "select * from ezcash_sample";
 
 $stmt = oci_parse($conn, $or_sql);
 oci_execute($stmt);
      
      while($row = oci_fetch_array($stmt)){
            echo '<pre>';
            echo $row[0]."   ".$row[1]."   ".$row[2]."   ".$row[3]."   ".$row[4];    //database column
            echo '</pre>';
            
            }
      
 
   oci_close($conn);
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question