By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Character conversion between oracle and php?

P: n/a
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_PARAMETERS".
" union".
" select 'print1', 'שעאטלי' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$nrows = OCIFetchStatement($stmt, $results);

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

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

}

print ("<pre>print2: שעאטלי</pre>\n");

OCIFreeStatement($stmt);
OCILogoff($conn);

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALENDAR: GREGORIAN</pre>
<pre>NLS_COMP: BINARY</pre>
<pre>NLS_CURRENCY: $</pre>
<pre>NLS_DATE_FORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_LANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_CURRENCY: $</pre>
<pre>NLS_ISO_CURRENCY: AMERICA</pre>
<pre>NLS_LANGUAGE: AMERICAN</pre>
<pre>NLS_LENGTH_SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERIC_CHARACTERS: .,</pre>
<pre>NLS_SORT: BINARY</pre>
<pre>NLS_TERRITORY: AMERICA</pre>
<pre>NLS_TIMESTAMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMESTAMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_FORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_TZ_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
Share this Question
Share on Google+
2 Replies


P: n/a
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_PARAMETERS".
" union".
" select 'print1', 'שעאטלי' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$nrows = OCIFetchStatement($stmt, $results);

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

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

}

print ("<pre>print2: שעאטלי</pre>\n");

OCIFreeStatement($stmt);
OCILogoff($conn);

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALENDAR: GREGORIAN</pre>
<pre>NLS_COMP: BINARY</pre>
<pre>NLS_CURRENCY: $</pre>
<pre>NLS_DATE_FORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_LANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_CURRENCY: $</pre>
<pre>NLS_ISO_CURRENCY: AMERICA</pre>
<pre>NLS_LANGUAGE: AMERICAN</pre>
<pre>NLS_LENGTH_SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERIC_CHARACTERS: .,</pre>
<pre>NLS_SORT: BINARY</pre>
<pre>NLS_TERRITORY: AMERICA</pre>
<pre>NLS_TIMESTAMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMESTAMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_FORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_TZ_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

P: n/a
ka*****@virgilio.it (Kamal) wrote in message news:<4e**************************@posting.google. 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_PARAMETERS".
" union".
" select 'print1', 'שעאטלי' from dual";

$stmt = OCIParse($conn, $sql);
OCIExecute($stmt);
$nrows = OCIFetchStatement($stmt, $results);

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

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

}

print ("<pre>print2: שעאטלי</pre>\n");

OCIFreeStatement($stmt);
OCILogoff($conn);

?>

</body>
</html>

and it prints:
<html>
<body>

<pre>NLS_CALENDAR: GREGORIAN</pre>
<pre>NLS_COMP: BINARY</pre>
<pre>NLS_CURRENCY: $</pre>
<pre>NLS_DATE_FORMAT: DD-MON-RR</pre>
<pre>NLS_DATE_LANGUAGE: AMERICAN</pre>
<pre>NLS_DUAL_CURRENCY: $</pre>
<pre>NLS_ISO_CURRENCY: AMERICA</pre>
<pre>NLS_LANGUAGE: AMERICAN</pre>
<pre>NLS_LENGTH_SEMANTICS: BYTE</pre>
<pre>NLS_NCHAR_CONV_EXCP: FALSE</pre>
<pre>NLS_NUMERIC_CHARACTERS: .,</pre>
<pre>NLS_SORT: BINARY</pre>
<pre>NLS_TERRITORY: AMERICA</pre>
<pre>NLS_TIMESTAMP_FORMAT: DD-MON-RR HH.MI.SSXFF AM</pre>
<pre>NLS_TIMESTAMP_TZ_FORMAT: DD-MON-RR HH.MI.SSXFF AM TZR</pre>
<pre>NLS_TIME_FORMAT: HH.MI.SSXFF AM</pre>
<pre>NLS_TIME_TZ_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 discussion thread is closed

Replies have been disabled for this discussion.