Character conversion between oracle and php?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kamal

    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
  • Henk Verhoeven

    #2
    Re: Character conversion between oracle and php?

    Hi Kamal,

    Maybe Oracle is only storing 7 bits ASCII ?

    Greetings,

    Henk Verhoeven,
    www.phpPeanuts.org.



    Kamal wrote:[color=blue]
    > 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[/color]

    Comment

    • cjbj

      #3
      Re: Character conversion between oracle and php?

      kamal80@virgili o.it (Kamal) wrote in message news:<4e766a02. 0407120307.5e35 166f@posting.go ogle.com>...[color=blue]
      > 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[/color]

      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
      Access cloud trials and software downloads for Oracle applications, middleware, database, Java, developer tools, and more.

      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
      Access cloud trials and software downloads for Oracle applications, middleware, database, Java, developer tools, and more.


      -- CJ

      Comment

      Working...