473,839 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Character conversion between oracle and php?

PHP 4.3.4 on Apache 2.0.48 on Linux Red Hat 8.0 Kernel 2.4.18-14smp
with Oracle 9iR2.

I have this code:

<html>
<body>

<?php

$conn = OCILogon('user' , 'pwd', 'db');

$sql = "select PARAMETER, VALUE from NLS_SESSION_PAR AMETERS".
" union".
" select 'print1', '' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stm t);
$nrows = OCIFetchStateme nt($stmt, $results);

for ( $i = 0; $i < $nrows; $i++ ) {

$p = $results["PARAMETER"][$i];
$v = $results["VALUE"][$i];
print ("<pre>$p: $v</pre>\n");

}

print ("<pre>print 2: </pre>\n");

OCIFreeStatemen t($stmt);
OCILogoff($conn );

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALEND AR: GREGORIAN</pre>
<pre>NLS_COMP : BINARY</pre>
<pre>NLS_CURREN CY: $</pre>
<pre>NLS_DATE_F ORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_L ANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_C URRENCY: $</pre>
<pre>NLS_ISO_CU RRENCY: AMERICA</pre>
<pre>NLS_LANGUA GE: AMERICAN</pre>
<pre>NLS_LENGTH _SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_ CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERI C_CHARACTERS: .,</pre>
<pre>NLS_SORT : BINARY</pre>
<pre>NLS_TERRIT ORY: AMERICA</pre>
<pre>NLS_TIMEST AMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMEST AMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_F ORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_T Z_FORMAT: HH.MI.SSXFF AM TZR</pre>
<pre>print1: yr`hli</pre>
<pre>print2: </pre>

</body>
</html>

Why? Why? Why "print1" is so strange?

Thank you in advance.

Kamal
Jul 17 '05 #1
2 2693
Hi Kamal,

Maybe Oracle is only storing 7 bits ASCII ?

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

Kamal wrote:
PHP 4.3.4 on Apache 2.0.48 on Linux Red Hat 8.0 Kernel 2.4.18-14smp
with Oracle 9iR2.

I have this code:

<html>
<body>

<?php

$conn = OCILogon('user' , 'pwd', 'db');

$sql = "select PARAMETER, VALUE from NLS_SESSION_PAR AMETERS".
" union".
" select 'print1', '' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stm t);
$nrows = OCIFetchStateme nt($stmt, $results);

for ( $i = 0; $i < $nrows; $i++ ) {

$p = $results["PARAMETER"][$i];
$v = $results["VALUE"][$i];
print ("<pre>$p: $v</pre>\n");

}

print ("<pre>print 2: </pre>\n");

OCIFreeStatemen t($stmt);
OCILogoff($conn );

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALEND AR: GREGORIAN</pre>
<pre>NLS_COMP : BINARY</pre>
<pre>NLS_CURREN CY: $</pre>
<pre>NLS_DATE_F ORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_L ANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_C URRENCY: $</pre>
<pre>NLS_ISO_CU RRENCY: AMERICA</pre>
<pre>NLS_LANGUA GE: AMERICAN</pre>
<pre>NLS_LENGTH _SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_ CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERI C_CHARACTERS: .,</pre>
<pre>NLS_SORT : BINARY</pre>
<pre>NLS_TERRIT ORY: AMERICA</pre>
<pre>NLS_TIMEST AMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMEST AMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_F ORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_T Z_FORMAT: HH.MI.SSXFF AM TZR</pre>
<pre>print1: yr`hli</pre>
<pre>print2: </pre>

</body>
</html>

Why? Why? Why "print1" is so strange?

Thank you in advance.

Kamal


Jul 17 '05 #2
ka*****@virgili o.it (Kamal) wrote in message news:<4e******* *************** ****@posting.go ogle.com>...
PHP 4.3.4 on Apache 2.0.48 on Linux Red Hat 8.0 Kernel 2.4.18-14smp
with Oracle 9iR2.

I have this code:

<html>
<body>

<?php

$conn = OCILogon('user' , 'pwd', 'db');

$sql = "select PARAMETER, VALUE from NLS_SESSION_PAR AMETERS".
" union".
" select 'print1', '' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stm t);
$nrows = OCIFetchStateme nt($stmt, $results);

for ( $i = 0; $i < $nrows; $i++ ) {

$p = $results["PARAMETER"][$i];
$v = $results["VALUE"][$i];
print ("<pre>$p: $v</pre>\n");

}

print ("<pre>print 2: </pre>\n");

OCIFreeStatemen t($stmt);
OCILogoff($conn );

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALEND AR: GREGORIAN</pre>
<pre>NLS_COMP : BINARY</pre>
<pre>NLS_CURREN CY: $</pre>
<pre>NLS_DATE_F ORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_L ANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_C URRENCY: $</pre>
<pre>NLS_ISO_CU RRENCY: AMERICA</pre>
<pre>NLS_LANGUA GE: AMERICAN</pre>
<pre>NLS_LENGTH _SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_ CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERI C_CHARACTERS: .,</pre>
<pre>NLS_SORT : BINARY</pre>
<pre>NLS_TERRIT ORY: AMERICA</pre>
<pre>NLS_TIMEST AMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMEST AMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_F ORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_T Z_FORMAT: HH.MI.SSXFF AM TZR</pre>
<pre>print1: yr`hli</pre>
<pre>print2: </pre>

</body>
</html>

Why? Why? Why "print1" is so strange?

Thank you in advance.

Kamal


What value of NLS_LANG does the PHP have? This is the Oracle client-
side setting that will dictate character set conversion between the
database and the Oracle call interface. To find out, run the
phpinfo() script mentioned in
http://otn.oracle.com/tech/opensourc...q.html#envvars
Check that the character set is the same or a superset of the database character
set.

Also see "An Overview on Globalizing Oracle PHP Applications" at
http://otn.oracle.com/tech/opensourc...plications.pdf

-- CJ
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12649
by: Barry Young | last post by:
I am using the following code to insert a row in an Oracle Database. strConnection = "Provider=OraOLEDB.Oracle;Data Source=MYDATABASE;User Id=SYSTEM;Password=******" Dim strMessage As String Dim objConnection As New OleDb.OleDbConnection(strConnection) Dim objCommand As OleDb.OleDbCommand
5
2447
by: Shock | last post by:
Hello all, I am doing some research on database conversions. Currently, I am interested in any information that would help me convert a database from one schema to another. This could be changes as minimal as adding a field to a table, or as large as deleting tables and changing relationships. Unfortunately, my experience with SQL Server is minimal. I know how to do a lot, but I do not know a lot of intricacies that most experts...
1
7779
by: Jim Shank | last post by:
I am adding support to my application for Oracle 10g and using Enterprise Library Data Access Application Blocks and trying to determine the best way to convert the GUID's which are stored as RAW(16) in Oracle (Byte Arrays) back to GUID's in my data layer. My best guess is a conversion method that the DataSet goes through before leaving the data access layer. Here is my code: Private Sub Raw16ToGuid(ByRef dataSet As DataSet) Dim...
1
2294
by: bala | last post by:
Hi Access Gurus The MS Access DB (MS Access 2002 Database) which is currently serving as the backend Database to MS Access (MS Access 2002/XP) frontend needs to be converted to Oracle 8i Backend (With the frontend still being MS Access 2002). The Client is very particular about the conversion. Would appreciate if any suggestion can be given as to how to start and go ahead with conversion. Whether the Upsize Wizard used by MS Access...
23
3203
by: Akhil | last post by:
Since a character constant is an int value represented as a character in single quotes,so it is treated as a 1 byte integer now look at the following snippet. #include<stdio.h> int main(void) { char a='Abbc'; printf("%c",a);
5
20739
by: Joper | last post by:
Hi, I'm getting the ORA-00911:invalid character when trying to do a query to a Oracle database from a Excel VBA Macro. I'm using the following code extraction: ----BEGIN CODE----- Sub GDataTeste() Dim cn As New ADODB.Connection
2
10318
by: Jason | last post by:
Hi, I was wondering if anyone could advise me on this. Right now I am setting up a DB2 UDB V8.2.3 database with UTF8 character set, which will work with a J2EE application running on WebSphere Application Server. I have two questions: 1. How many characters, such as Chinese, Japanese, can a CHAR(128) or
17
10716
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when talking with another team -- codepage -- at the same time. I am more confused when I saw sometimes we need codepage parameter for wide character conversion, and sometimes we do not need for conversion. Here are two examples,
6
4068
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me. But, the password filter needs to be built, so I'm doing my best. First of all, I am creating an xml string that contains both username and password, and then I want to write the ascii values for all characters to a textfile. By using the...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7834
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.