Solved

Warning: expects parameter 1 to be resource

Posted on 2013-12-12
5
1,597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

626 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