Solved

Connecting to Oracle using PHP - retrieving data

Posted on 2011-02-16
1
382 Views
Last Modified: 2012-05-11
I am trying to connect to oracle through php code.
I tested the connection to the database and that seems to be OK but having problem connecting to the table. I am MS SQL Server/Mysql user and never used schema's in there. In Oracle table that I am trying to connect lives in a Schema. How do I pass the correct Schema info in PHP. That's the only thing I assume is missing in this puzzle.

Structure of my Oracle database:

Server>Database>Schema>Table
<?php
	
	$conn = oci_connect ( 'username', 'password', 'ServerName/DatabaseName') or exit (mysql_error());
	//mysql_select_db('test');
	
	// only select the columns you need, thus reducing the work the DBMS has to do.
	$query = "SELECT * FROM TableName";
	// execute the query
	$results = oci_parse ($conn, 'SELECT * FROM TableName'); //or exit(oci_error());
	
	echo "test 1";
	oci_execute($results);
	
	echo "end test 1";
	
	// check for the number of rows returned before doing any further actions.
	if ($row = oci_fetch_array($results) == 0){
	exit("Nothing to Show Here");
	}

?>


Errors/Warnings:
1 - "Table or view doesn't exist" at the line: 
$results = oci_parse ($conn, 'SELECT * FROM TableName');

2 - "ORA-24374: define not done before fetch or execute and fetch" at line: 
if ($row = oci_fetch_array($results) == 0){

Open in new window

0
Comment
Question by:awarraic
[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
1 Comment
 
LVL 7

Accepted Solution

by:
tlovie earned 500 total points
ID: 34908771
wouldn't you do it in the select statement like this:

'SELECT * FROM schema.TableName'
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to recover a database from a user managed backup

749 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