[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 11-18-2003, 06:51 PM   · #1
Tracy
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 2
NP$: 3.00 (Donate)
Tracy is an unknown quantity at this point
Problem with Oracle/PHP/Solaris

Hello All,

I'm an old client-server dog learning new tricks; specifically Web Applications. I'm having a bit of a problem getting a result set back from a remote DB.

Background:

Database Server: Oracle 9iR2 running on Solaris 8 OS
Web Server: Solaris 8 OS with Apache and PHP 4.3.4

The Apache and PHPinfo() web pages come up normally.

Problem: I can log into in the Scott/Tiger Demo schema on the DB Server, but when I send a query to the EMP table, I get zero rows returned. I check the EMP table through SQL*Plus Worksheet and it has 14 rows.

Here's the PHP code I use for the web page:


<?
putenv("ORACLE_HOME=/opt/oracle");

$username = "scott";
$password = "tiger";
$db = "(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = xxx.xxx.xxx.xxx)
(PORT = 1521)
)
)
(CONNECT_DATA = (SID=sssssss) )
)";

$conn = OCILogon($username,$password,$db);

if (!$conn)
{
echo "Connection Failed. ";
echo "Error Message: [" . OCIError($conn) . "] <br><br>n";
die();
}
else
{
echo "Connected: ".$conn."<br><br>n";
}

$stmt = ociparse($conn,"SELECT ENAME, SAL FROM SCOTT.EMP");
ociexecute($stmt,OCI_DEFAULT);

$nrows = ocifetchstatement($stmt, $results);
echo "<br><br>Found: $nrows results<br><br>n";

echo "<table border=1 cellspacing='0' width='50%'>n";

echo "<tr>n";
echo "<td><b>Name</b></td>n";
echo "<td><b>Salary</b></td>n";
echo "<tr>n";

for ($i = 0; $i < $nrows; $i++ )
{
echo "<tr>n";
echo "<td>" . $results["ENAME"][$i] . "</td>";
echo "<td>$ " . number_format($results["SAL"][$i], 2). "</td>";
echo "</tr>n";
}
echo "</table>n";

ocilogoff($conn);
?>


I get zero rows returned after I receive a sucessful connection. I also tried using two other OCI functions: OCIFetch and OCIFetchInto. Same result: zero row count.

I ran the SQL statement in SQL*Plus and it executed.

Anyone see behavior like this before? Thoughts, opinions?


Respectfully,
Tracy-Paul Warrington


Please register or log-in into NamePros to hide ads
Tracy is offline   Reply With Quote
Old 11-18-2003, 09:02 PM   · #2
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
I really don't know anything about oracle, but I wonder if selecting everything such as SELECT * FROM SCOTT.EMP will make $nrows display the number of results/rows? Have you tried that?
deadserious is offline   Reply With Quote
Old 11-18-2003, 11:43 PM   · #3
Tracy
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 2
NP$: 3.00 (Donate)
Tracy is an unknown quantity at this point
I'll give a shot tomorrow and see what happens. Although I doubt if it'll change the behavior. It seems to me that OCIFetchStatement would return all rows the query specified; regardless of the number of columns.

But, WTH, couldn't hurt to try...
Tracy is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Arcade Script Hunting Moon Buy Flash Arcade Game Script
Advertise your business at NamePros
All times are GMT -7. The time now is 09:42 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0