473,322 Members | 1,911 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,322 software developers and data experts.

How do i change my entire database (including fields!) to UTF-8?

113 100+
Hi,

I've been struggling to find a solution this problem, I have found the following php script:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $db = mysql_connect('localhost','myuser_mydbuser','mypassword');
  3. if(!$db) echo "Cannot connect to the database - incorrect details";
  4. mysql_select_db('myuser_mydbname'); $result=mysql_query('show tables');
  5. while($tables = mysql_fetch_array($result)) {
  6. foreach ($tables as $key => $value) {
  7. mysql_query("ALTER TABLE $value COLLATE utf8_general_ci");
  8. }}
  9. echo "The collation of your database has been successfully changed!";
  10. ?>
  11.  
This however does not do what it says on the tin, instead it just changes the table collation to utf8_general_ci, what I need is for it to change the fields as well as these are remaining the same.

Is there a fast way to do this?

The reason why i 'think' i need to do this is so that i can server up pages AND RSS feeds encoded in the utf-8 format, as I am having trouble with wierd characters in my feed.

Thanks,

Chromis
Dec 10 '08 #1
1 1705
Atli
5,058 Expert 4TB
Hi.

I am not sure that changing the charset of your database will have the effect you are hoping for.

If you need to display ISO characters in a Unicode page, try using the utf8_encode function.
Dec 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ray | last post by:
Dear all, By using the following code, I can change the database name of the crystal report .... Dim ReportTemp As New ReportDocument ReportTemp.Load(_report) For Each table In...
19
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested...
1
by: yateen joshi | last post by:
Hi , I am developing a script that will delete old data from various tables in a database periodically. The script deletes data from all the tables, one by one, in single go. I have two options...
2
by: AboutJAV | last post by:
Hi, I read alot of articles on how to read 1 table to a dataset. How do you read and entire database to a dataset, do a fill, and update it after modification. Thanks
2
by: resdi hadi | last post by:
Hello can help me?... I am beginner How to delete n change my database access with VB? pls...
3
by: tanyali | last post by:
I am using Linux RedHat , MySql Ver 14.12 Distrib 5.0.18 not enough disk space left on /dev/sda7, which I am working on, I insert BLOBs into database and the table is as big as 5.54468 GB I...
9
by: ischwartz88 | last post by:
Hi, I am not a computer programmer. I have been learning VBA along the way of making this script. I know Access and SQL. I have a very large database with many tables and queries. My goal is to...
15
by: NitinSawant | last post by:
I'm developing app. using C# and SQL Server 2005, What i'm trying to do is "Update User Interface when there is change in database", suppose, there is datagrid on a form.. two different...
0
by: sentimental37 | last post by:
I want to change the database in my app. where i m using access as backend and C# as frontend.I saw con.ChangeDatabase but i dont know how to use it plzzz help
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.