Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
php.ini mysql.connect_charset
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
natanver
n00b
n00b


Joined: 17 Jul 2012
Posts: 47

PostPosted: Tue Dec 11, 2012 1:53 pm    Post subject: php.ini mysql.connect_charset Reply with quote

After upgrading from PHP 5.2 to PHP 5.3.15
the php.ini directive : "mysql.connect_charset = latin1" seems to be broken.

How can the old behaviour being restored?

I suppose you could use

mysql_query('SET NAMES latin1;');

But I don't want - I can not - make changes to the existing php-code.

Regards,

Natan

same applies for:
mysqli.connect_charset = latin1
pdo_mysql.connect_charset = latin1
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Tue Dec 11, 2012 10:59 pm    Post subject: Reply with quote

What do you mean by "is broken"? Are there error messages, or do you just experience messed up strings?

If you have access to the mysql configuration (/etc/my.cnf), you might try to set latin1 as default charset there.
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
natanver
n00b
n00b


Joined: 17 Jul 2012
Posts: 47

PostPosted: Wed Dec 12, 2012 10:21 am    Post subject: Reply with quote

lxg wrote:
What do you mean by "is broken"?


it seems the mysql.connect_charset php.ini directive doesn't exist anymore

output phpinfo() PHP 5.2.17
Code:
Directive   Local Value   Master Value
mysql.allow_persistent   On   On
mysql.connect_charset   latin1   latin1
mysql.connect_timeout   60   60
mysql.default_host   no value   no value
mysql.default_password   no value   no value
mysql.default_port   no value   no value
mysql.default_socket   no value   no value
mysql.default_user   no value   no value
mysql.max_links   Unlimited   Unlimited
mysql.max_persistent   Unlimited   Unlimited
mysql.trace_mode   Off   Off


output phpinfo() PHP 5.3.15
Code:
Directive   Local Value   Master Value
mysql.allow_local_infile   On   On
mysql.allow_persistent   On   On
mysql.connect_timeout   60   60
mysql.default_host   no value   no value
mysql.default_password   no value   no value
mysql.default_port   no value   no value
mysql.default_socket   /var/run/mysqld/mysqld.sock   /var/run/mysqld/mysqld.sock
mysql.default_user   no value   no value
mysql.max_links   Unlimited   Unlimited
mysql.max_persistent   Unlimited   Unlimited
mysql.trace_mode   Off   Off


lxg wrote:
Are there error messages, or do you just experience messed up strings?

There are no error messages, only messed up strings.

lxg wrote:
If you have access to the mysql configuration (/etc/my.cnf), you might try to set latin1 as default charset there.

yes, I have access to /etc/my.cnf

latin1 was already defined as default charset.
Code:
[mysqld]
character-set-server      = latin1
character_set_client      = latin1
default-character-set   = latin1


Is there some info on why mysql.connect_charset disappeared ?
How to adjust settings to regain previous behaviour ?

Thanks,
Natan
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Wed Dec 12, 2012 10:27 am    Post subject: Reply with quote

https://www.google.de/search?q="mysql.connect_charset"+"php+5.3"
https://bugs.php.net/bug.php?id=44118

This appears to be a known bug which they are reluctant to fix.

I understand that it's hard to patch legacy code ... but if I were in your place, I'd simply put that "SET NAMES" command directly into your DB component, right after the mysql_connect() stuff. So you just need to make one change. Plus, your code will become more portable, as you don't rely on a local configuration setting.
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
natanver
n00b
n00b


Joined: 17 Jul 2012
Posts: 47

PostPosted: Wed Dec 12, 2012 5:36 pm    Post subject: Reply with quote

thanks lgx, but I need a server-wide solution

To make all the queries use the SET NAMES parameter is a real pain...

I tried adding this in my.cnf

Code:
[mysqld]
init_connect='SET NAMES latin1'


without success.

any suggestions?

Thanks,
Natan
Back to top
View user's profile Send private message
natanver
n00b
n00b


Joined: 17 Jul 2012
Posts: 47

PostPosted: Thu Dec 13, 2012 3:26 pm    Post subject: Reply with quote

natanver wrote:
thanks lgx, but I need a server-wide solution

To make all the queries use the SET NAMES parameter is a real pain...

I tried adding this in my.cnf

Code:
[mysqld]
init_connect='SET NAMES latin1'


without success.

any suggestions?

Thanks,
Natan


correction.

adding

Code:
[mysqld]
init_connect='SET NAMES latin1'


into my.cnf does solve the problem.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum