Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Warning: expects parameter 1 to be resource

Posted on 2013-12-12
5
Medium Priority
?
1,694 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 500 total points
ID: 39715766
while (($row = oci_fetch_array($statement))) {
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 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 111

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
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…

670 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