If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > codepage iso-8859-2 DB2 -> php

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-09, 15:15
maro20 maro20 is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
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"); 
Reply With Quote
  #2 (permalink)  
Old 06-17-09, 06:09
Fredodido Fredodido is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 06-17-09, 06:33
maro20 maro20 is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On