473,775 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1344
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.comwrot e:
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
15926
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 hooked up to interfaces. The Gtk is more than enough gui.
2
1133
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
3081
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 Corrupted Things we have tried We are not using server.transfer. We have verified the machine keys in the machine.config file on both nodes of the cluster.
3
2196
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> <HEAD> </HEAD> <body>
2
2606
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
1468
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 request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The viewstate is invalid for this page and might be corrupted.
3
8707
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: System.Convert.FromBase64String(String s) +0
14
1347
by: a.schoeni | last post by:
I got the folowing problem: www.pennergame.de/ref.php?uid=2925
4
1315
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 rows in a database so a database lookup is done for each object created. I noticed that running certain scripts could result in the same object being created in the factory multiple times (ie the same database row might be used to instantise...
0
1051
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. Careful shopping for the best prices might require a shopper to lower standards and choose something that was worn once and never again. In this instance, quality and price would be the factors to consider when comparison-shopping for fine...
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.