473,769 Members | 5,205 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 2686
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
12645
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
2445
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
7772
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
2289
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
3194
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
20733
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
10308
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
10709
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
9589
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10050
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...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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
7413
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
5310
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.