Solved

Warning: expects parameter 1 to be resource

Posted on 2013-12-12
5
1,318 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 82

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 108

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now