LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-10-2006, 09:31 AM   #1
suchi_sood
LQ Newbie
 
Registered: Apr 2006
Posts: 14

Rep: Reputation: 0
select statement not work in php with OCIEXEcute()


<?php
putenv("ORACLE_SID=crbtdb");
putenv("ORACLE_HOME=/home/oracle/product/9.2.0.1.0");
putenv("TNS_ADMIN=/home/oracle/product/9.2.0.1.0/network/admin/");
$userora = "crbtclient";
$passwdora = "crbtclient";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=leopard)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=crbtdb))
)";
if($db_conn = OCILogon($userora,$passwdora,$db))
{
echo "Successfully connected to Oracle.\n";
}
else {
echo "Oracle Connect Error " . ocierror($db_conn);
}
$cmdstr = "select DN from ALLOWED_DNS like ";
$stmt = OCIParse($db_conn, $cmdstr);
OCIError($stmt);

$exec=OCIExecute($stmt);
OCIError($exec);
$nrows=ocifetchstatement($stmt, $results);
echo $nrows;
ocicommit($db_conn);
ocilogoff($db_conn);

gives an error
Successfully connected to Oracle.
Warning: OCIStmtExecute: Error while trying to retrieve text for error ORA-03106 in /var/www/html/CRBT/SUCHI/login.php on line 37


where as insert into table command works perfectly why..

using php4.1.2 with oracle 9i

if the datatype of the value is int then the select command works..
wheras in case of varchar2(20) ..it does not fetch the records..

Last edited by suchi_sood; 04-10-2006 at 10:08 AM.
 
Old 04-10-2006, 11:12 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You select doesn't look as if has been completed
Code:
select DN from ALLOWED_DNS like
like what?
 
Old 04-10-2006, 11:25 PM   #3
suchi_sood
LQ Newbie
 
Registered: Apr 2006
Posts: 14

Original Poster
Rep: Reputation: 0
select statement does work

it is select dn frpm allowed_dns
writin mistake it cwas..
this query does work in sql promt..
yes i m able to be connected in oracle..
select statemrnt works on the table where data type is int..
if the data type is varchar2(10) then gives an error
OCIStmtExecute: Error while trying to retrieve text for error ORA-03117
 
Old 04-11-2006, 01:34 AM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Look at your environment variables.

Don't trust PHP "putenv()" to set the variables correctly - set ORACLE_HOME. ORACLE_SID, NLS_LANG, etc at the *apache* level (not in your PHP script).

Here's another link (besides the other links I posted in your other thread):
http://php.benscom.com/manual/es/function.ocilogon.php

Good luck!
 
Old 04-11-2006, 01:49 AM   #5
suchi_sood
LQ Newbie
 
Registered: Apr 2006
Posts: 14

Original Poster
Rep: Reputation: 0
set the enviornment variables in httpd.conf file as well..
but of no use..
cant find the correct ans...


SetEnv ORACLE_HOME /home/oracle/product/9.2.0.1.0
SetEnv ORA_NLS33 /home/oracle/product/9.2.0.1.0/ocommon/nls/admin/data
SetEnv NLS_LANG AMERICAN
SetEnv TWO_TASK /home/oracle/product/9.2.0.1.0/network/admin/tnsnames.ora
SetEnv LD_LIBRARY_PATH /home/oracle/product/9.2.0.1.0/lib:/lib:/usr/lib:/usr/local/lib
SetEnv ORACLE_SID crbtdb
SetEnv TNS_ADMIN /home/oracle/product/9.2.0.1.0/network/admin/tnsnames.ora
SetEnv NLS_CHARACTERSET "WE8DEC"
SetEnv NLS_NCHAR_CHARACTERSET "AL16UTF16"
 
Old 04-11-2006, 03:31 AM   #6
smallville
Member
 
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
i think you have to correct your sql query, as the oher user said, LIKE what?????
 
Old 04-11-2006, 04:03 AM   #7
suchi_sood
LQ Newbie
 
Registered: Apr 2006
Posts: 14

Original Poster
Rep: Reputation: 0
not solved..

plz tell what changes have to be made in sql area..
be atleast little precise.
any expert in php n oracle
 
Old 04-11-2006, 10:07 AM   #8
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Well initially I'd change
Code:
$cmdstr = "select DN from ALLOWED_DNS like ";
$stmt = OCIParse($db_conn, $cmdstr);
to

Code:
$cmdstr = "select DN from ALLOWED_DNS";
$stmt = OCIParse($db_conn, $cmdstr);
That at least looks like a valid sql statement to me.
 
Old 04-11-2006, 11:22 PM   #9
suchi_sood
LQ Newbie
 
Registered: Apr 2006
Posts: 14

Original Poster
Rep: Reputation: 0
already made the correction ..
plz suggest the appropriate ans
 
Old 04-12-2006, 06:22 AM   #10
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Have you changed the httpd.conf as PaulSM suggested?
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
If statement doesn't work properly in JavaScript Robhogg Programming 2 03-05-2006 03:30 PM
php mysql select msound Programming 9 05-21-2005 08:44 PM
Select Box, PHP agallant Programming 8 08-04-2004 01:15 PM
[PHP+MySQL] Rotate order in SELECT pnh73 Programming 5 12-31-2003 04:10 PM
Bash select statement and spaces meshcurrent Linux - General 2 04-09-2003 09:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration