Solved

Connecting to Oracle using PHP - retrieving data

Posted on 2011-02-16
1
375 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
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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 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

12 Experts available now in Live!

Get 1:1 Help Now