473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Might be PHP after all

I found the mysql group on google and posted a question (which I'll attach
below). On thinking about it, it might be a php problem after all. I can
see the data properly via phpMyAdmin (an apostrophe is an apostrophe).
However, on looking at the retrieved results in php, the apostrophe takes on
an odd three character sequence. Also, in looking at the text file in
MSWord, I see apostrophes, but they look different than the apostrophe used
to delimit a field value. When I try to do a replace on the apostrophes I
want, it picks them all out to replace.

So, this might be php after all.

(Side note to Jerry: The activity in that group is about 30 posts/replies
per day, with two of them from you. Not a very active group -- but
passable).

Here is what I posted there:

************
I have to port data from MySQL 4.1.x to MySql 4.0.27 (The client is
changing hosts). Call these S for source and D for destination.

On D, if I put in data with an apostrophe (using addslashes), it goes
in fine and comes out fine. However, data from S which is now in D
via an export/import (done already, but I can redo it if needed) when
retrieved via PHP comes up with a strange sequence of âEURO(tm) instead of
an apostrophe. Also, the e with the back accent mark as in Café comes
out CafĂ(c),

S has a default character set of lantin1, while D has a character set
of utf8.

I have tried an "alter table foo character set latin1" on D. No
help. I have then gone and put it back to utf8. Nothing changes. I
have also tried exporting from S specifying it as utf8 and importing
it on D. No luck there either.

When I go into phpMyAdmin and look at the data, I see an apostrophe.

Short of digging through all the data and doing an update, or looking
at the export from D, massaging it, and reimporting it, I don't know
how to fix these data.

Any help is welcome.
***********

With a followup of:

**********
One more thing. When I look at the text file that was exported from
S, I see apostrophes, yet when I then import it to D and look at it I
see the junk. (I created a new table and did this for testing
purposes).
*********

--
Shelly
Nov 15 '07 #1
6 1330
I have to port data from MySQL 4.1.x to MySql 4.0.27 (The client is
changing hosts). Call these S for source and D for destination.

On D, if I put in data with an apostrophe (using addslashes), it goes
in fine and comes out fine. However, data from S which is now in D
via an export/import (done already, but I can redo it if needed) when
retrieved via PHP comes up with a strange sequence of âEURO(tm) instead of
an apostrophe. Also, the e with the back accent mark as in Café comes
out CafĂ(c),

S has a default character set of lantin1, while D has a character set
of utf8.
OK. Let's anlyse this. What you are seeing if utf-8, but rendered as
latin-1. It is a real pity that you have to backport data, as encoding
support only gets better with the versions. Therefore, getting back
makes things worse. Your best bet is to adapt the database in the most
recent version of the two and then backport it.

But if you get utf-8 anyway (even if rendered incorrectly), I suppose
this went well. You can always check by using the mysql_dump utility and
see what strings it generates. This is one of the few reliable methods
to see how the strings are stored.

So what is wrong is that you see data in utf-8, but your client does not
know it.

Take a look at my.cnf (your MySQL config file). It contains a section
[mysql], a section [mysqld] and a section [client]. Check if the client
section has its "character set" option set to utf-8.
>
I have tried an "alter table foo character set latin1" on D. No
help. I have then gone and put it back to utf8. Nothing changes. I
have also tried exporting from S specifying it as utf8 and importing
it on D. No luck there either.

When I go into phpMyAdmin and look at the data, I see an apostrophe.

Short of digging through all the data and doing an update, or looking
at the export from D, massaging it, and reimporting it, I don't know
how to fix these data.

So far, it could be a mysql issue. But you have not told us what
application renders the query results. If you have a web page that just
tells the browser to render "text/html; charset=iso-8859-1" and send
strings in utf-8, it is clear that you will get the above output. In
that case, it is a PHP problem.

It can be solved by sending the correct encoding. This can be done in
PHP.INI (server-wide, or from an apache config section-wide), or just by
sending the appropriate Content-Type header "by hand".

Good luck!
Nov 15 '07 #2
On Thu, 15 Nov 2007 15:50:50 +0100, Shelly
<sh************@asap-consult.comwrote:
I found the mysql group on google and posted a question (which I'll
attach
below).
Such impatience...
--
Rik Wasmus
Nov 15 '07 #3
Dikkie Dik wrote:
>I have to port data from MySQL 4.1.x to MySql 4.0.27 (The client is
changing hosts). Call these S for source and D for destination.

On D, if I put in data with an apostrophe (using addslashes), it goes
in fine and comes out fine. However, data from S which is now in D
via an export/import (done already, but I can redo it if needed) when
retrieved via PHP comes up with a strange sequence of âEURO(tm)
instead of an apostrophe. Also, the e with the back accent mark as
in Café comes out CafĂ(c),

S has a default character set of lantin1, while D has a character set
of utf8.

OK. Let's anlyse this. What you are seeing if utf-8, but rendered as
latin-1. It is a real pity that you have to backport data, as encoding
support only gets better with the versions. Therefore, getting back
makes things worse. Your best bet is to adapt the database in the most
recent version of the two and then backport it.

But if you get utf-8 anyway (even if rendered incorrectly), I suppose
this went well. You can always check by using the mysql_dump utility
and see what strings it generates. This is one of the few reliable
methods to see how the strings are stored.

So what is wrong is that you see data in utf-8, but your client does
not know it.

Take a look at my.cnf (your MySQL config file). It contains a section
[mysql], a section [mysqld] and a section [client]. Check if the
client section has its "character set" option set to utf-8.
>>
I have tried an "alter table foo character set latin1" on D. No
help. I have then gone and put it back to utf8. Nothing changes. I
have also tried exporting from S specifying it as utf8 and importing
it on D. No luck there either.

When I go into phpMyAdmin and look at the data, I see an apostrophe.

Short of digging through all the data and doing an update, or looking
at the export from D, massaging it, and reimporting it, I don't know
how to fix these data.


So far, it could be a mysql issue. But you have not told us what
application renders the query results. If you have a web page that
The application is the web application that gets the data from the database
and shows it. It is obtain with a mysql_query and the succeeding commands.
just tells the browser to render "text/html; charset=iso-8859-1" and
send strings in utf-8, it is clear that you will get the above
output. In that case, it is a PHP problem.
It is "text/html; charset=iso-8859-1". So it IS a php problem?
It can be solved by sending the correct encoding. This can be done in
PHP.INI (server-wide, or from an apache config section-wide), or just
by sending the appropriate Content-Type header "by hand".
Changing Content-Type would do it? I'll look up what kind I need, but if
you would be so kind.....?

Shelly
Nov 15 '07 #4
Thank you Dikkie. Changing the header content type in the metadata to utf8
solved the problem. It displays properly now.

Rik, thank you as well for posting here and on comp.databases.mysql.

--
Shelly
Nov 15 '07 #5
It is "text/html; charset=iso-8859-1". So it IS a php problem?
>
>It can be solved by sending the correct encoding. This can be done in
PHP.INI (server-wide, or from an apache config section-wide), or just
by sending the appropriate Content-Type header "by hand".

Changing Content-Type would do it? I'll look up what kind I need, but if
you would be so kind.....?

just send a header "Content-Type: text/html; charset=utf-8"

I think it is time to read something about the subject:
http://www.joelonsoftware.com/articles/Unicode.html

Good luck with the onions.
Nov 15 '07 #6
Dikkie Dik wrote:
>It is "text/html; charset=iso-8859-1". So it IS a php problem?
>>It can be solved by sending the correct encoding. This can be done
in PHP.INI (server-wide, or from an apache config section-wide), or
just by sending the appropriate Content-Type header "by hand".

Changing Content-Type would do it? I'll look up what kind I need,
but if you would be so kind.....?


just send a header "Content-Type: text/html; charset=utf-8"

I think it is time to read something about the subject:
http://www.joelonsoftware.com/articles/Unicode.html

Good luck with the onions.
Thanks again. I found and did that on my own after your suggestion of
content type, but thanks for responding with the answer.

--
Shelly
Nov 15 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
2
by: lkrubner | last post by:
I need for my script to be able to find out what the domain name is for the site that it is running on. I looked through the $_SERVER vars, but didn't see anything.
1
by: Mike Turpin | last post by:
Can anyone provide some help on this issue? Our code works fine on a single machine but in a web farm environment we get the following error. The View State Is Invalid for This Page and Might Be...
3
by: Gvnn | last post by:
Hi, I've a little problem, i've an asp.net page, with a runat server form, like this: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb" Inherits="indexGstPro"%> <HTML>...
2
by: Mike | last post by:
hi to all does any body know or receive this message before and how i can repare this: The viewstate is invalid for this page and might be corrupted. thank's Mike
7
by: Jason | last post by:
Can anybody help on the following error : The viewstate is invalid for this page and might be corrupted. Description: An unhandled exception occurred during the execution of the current web...
3
by: Nathan Sokalski | last post by:
I am recieving the following error on the second postback of a page I have written: The state information is invalid for this page and might be corrupted Stack Trace: ...
14
by: a.schoeni | last post by:
I got the folowing problem: www.pennergame.de/ref.php?uid=2925
4
by: Gordon | last post by:
I'm using a factory pattern to generate objects, so I can check the success of the operation in the factory, return the object on success or return NULL on failure. The objects are abstractions of...
0
by: service0043 | last post by:
Some bargain prices can be found on jewelry that is sold in bulk and at auction houses on the internet. While the condition of the items might be used, some fine jewelry pieces will be sold as new....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.