Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008
    Posts
    2

    Unanswered: codepage iso-8859-2 DB2 -> php

    Hello. I'm doing a website in php and I'm using DB2.
    PHP Code:
    class connectPDO{
        private 
    $database,$user,$password,$hostname,$port;

        function 
    __construct() {
            
    $this->database 'db';
            
    $this->user 'user';
            
    $this->password 'pass';
            
    $this->hostname 'localhost';
            
    $this->port 50000;
        }

        public function 
    connect() {
            try{
                
    $conn_string='ibm:DRIVER={IBM*DB2*ODBC*DRIVER};HOSTNAME='.$this->hostname.';PORT='.$this->port.';DATABASE='.$this->database.';PROTOCOL=TCPIP;UID='.$this->user.';PWD='.$this->password;
                
    $pdo=new PDO($conn_string);
                return 
    $pdo;
            }catch(
    PDOException $err){
                print (
    "Error:".$err->getMessage());
            }
        }


    PHP Code:
    $ObPdo = new connectPDO();
    $pdo $ObPdo->connect();
    $pdo->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
    $sql='CALL infoForm(:str)';
    $stmt $pdo->prepare($sql);
    $str='name';
    $stmt->bindParam(':str'$strPDO::PARAM_STR);
    $stmt->execute();
    if( 
    $stmt ){
        
    $result=$stmt->fetchAll(PDO::FETCH_COLUMN);
        
    $tab=count($result);
        
    $newstring='<select name="'.$str.'">';
        for(
    $i=0$i<$tab $i++) {
            
    $newstring.='<option value="'.$i.'">'.$tab[$i].'</option>';
        }
        
    $newstring.='</select>';

        return 
    $newstring
    This query return bad string because I'm using /// content="text/html; charset=iso-8859-2" /// so how to change connecting/query (some examples) with base db2.

    To connecting with MySql I using
    PHP Code:
    mysql_query("set character_set_connection = latin2"); 

  2. #2
    Join Date
    Jun 2009
    Posts
    3
    Hi,

    I think you can not change db2 codepage by PHP

    on db2 console have you defined your DB Codepage ? 912 (latin2) using these commands :

    (your_instance is DB2 by default)

    set db2instance=your_instance
    db2set DB2CODEPAGE=912

  3. #3
    Join Date
    Dec 2008
    Posts
    2
    Yes. You are right. I changed the code page setdb2 db2codepage=1208 and in website source I changed the <meta http-equiv="Content-Type" content="text/html; charset=charset=UTF-8" /> and I have signs PL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •