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
Solved

Warning: expects parameter 1 to be resource

Posted on 2013-12-12
5
1,422 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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

789 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