Solved

Connecting to Oracle using PHP - retrieving data

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Via a live example, show how to take different types of Oracle backups using RMAN.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

690 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