Pervasive 10, PHP and ODBC

Last post 07-16-2010 4:35 AM by Gordon. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-13-2010 10:50 AM

    • Brasse
    • Not Ranked
    • Joined on 07-05-2010
    • Posts 4

    Pervasive 10, PHP and ODBC

    Hello, im experimenting with ODBC at the moment, and ive run in to a problem. Currently our business software lives in a Pervasive database, and unfortunately som column names contains swedish letters. For example: D2021_Företag So when i try this SQL: 'SELECT TOP 5 D2021_Företag FROM PUFIRMA' i get this error: Warning: odbc_exec() [function.odbc-exec]: SQL error: [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Invalid column name: 'D2021_Företag'., SQL state S0022 in SQLExecDirect in C:\xampp\htdocs\company.php on line 81 Im using PHP Version 5.3.1 Apache/2.2.14 (Win32) Windows 2003 How can i solve this?
  • 07-13-2010 11:07 AM In reply to

    Re: Pervasive 10, PHP and ODBC

     Try putting the names in "double quotes".

    Bill Bach
    Goldstar Software Inc.
    www.goldstarsoftware.com
  • 07-14-2010 1:10 AM In reply to

    • Brasse
    • Not Ranked
    • Joined on 07-05-2010
    • Posts 4

    Re: Pervasive 10, PHP and ODBC

    Yeah of course! Double quotes (") did not work, single quotes (') worked though. Thanks :) Edit. Did not check my result good enough, in my haste i assumed that no error message meant that it was working. Double quotes: $sql = 'SELECT TOP 25 "D2001_Företagskod" FROM PUFIRMA'; or $sql = "SELECT TOP 25 \"D2001_Företagskod\" FROM PUFIRMA"; results in: Warning: odbc_exec() [function.odbc-exec]: SQL error: [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Invalid column name: 'D2001_Företagskod'., SQL state S0022 in SQLExecDirect in C:\xampp\htdocs\orderstatus.php on line 93 $sql = "SELECT TOP 2 'D2001_Företagskod' FROM PUFIRMA"; results in: EXPR_1 D2001_Företagskod
  • 07-14-2010 2:57 AM In reply to

    • Brasse
    • Not Ranked
    • Joined on 07-05-2010
    • Posts 4

    Re: Pervasive 10, PHP and ODBC

    So, now i have more charset problems. when i do a normal SELECT and the returning result contains swedish characters (ÅÄÖåäö), it just displays wierd characters. Ive tried: header('Content-Type: text/html; charset=iso-8859-1); and header ('Content-type: text/html; charset=utf-8'); With different results, but none good. Ive also tried changing the "Database code page" in Pervasive Control Panel, between ISO8859-1, utf8 and server default. Im all out of ideas. What can i try next?
  • 07-16-2010 4:35 AM In reply to

    • Gordon
    • Top 25 Contributor
    • Joined on 08-30-2007
    • Delft, The Netherlands
    • Posts 282

    Re: Pervasive 10, PHP and ODBC

    It will most likely work if you substitute the raw hexcode characters with the literal values you require, like in this example:

    $search  = array (chr(132),chr(142),chr(148),chr(153),chr(129),chr(154),chr(225)); 
    $replace = array ('ä','Ä','ö','Ö','ü','Ü','ß');
    $newtext = str_replace($search, $replace, $text);

     

Page 1 of 1 (5 items)