PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Wed Apr 14, 2010 4:40 am Reply with quote Back to top

Hi to all of you. Today I created this little script in order to convert character latin1 to utf8. My question if I need to change anything else. I want to make a logo for that and change the abstraction if you can help me a little bit. What do you think. I tested and it is working properly. Very Happy

Code:
<?php
header('Content-type: text/plain;');
mysql_connect('localhost or IP','usernameofdatabase','password');
mysql_select_db('databasename');
$res = mysql_query("SHOW TABLES");
while ($r = mysql_fetch_array($res)){
  $tablename = $r[0];
  echo $sql = "ALTER TABLE $tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
  echo "\r\n";
mysql_query($sql);
}
?>




Another way to do it

How can I change my MySQL database collation from phpMyadmin?

Usually you will be interested in changing your MySQL collation in order to solve problems with foreign character encodings. The most common case is to change your MySQL collation from latin1 to utf8. This can be done by using phpMyAdmin and following the instructions below:


1. Enter your cPanel and click on the phpMyAdmin icon in the Databases box.

2. Select the database you wish to manage from the drop-down menu on the left



3. Click on the Operations tab in the top menu of your phpMyAdmin



4. At the bottom of the page you will see the collation option. You can now select a collation from the drop down menu and click on the Go button.


Please note that after your change the collation of a database only the new tables will be created with the new collation. All other tables remain with the collation, they were initially created
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Apr 17, 2010 4:59 pm Reply with quote Back to top

unicornio, you may be able to dump the table contents, change the collation, and then when importing back in, select the collation. I could have sworn I'd seen that process described somewhere. But, test it locally using XAMPP or similar environment FIRST. There will always be some characters/issues. One issue is even HTML entities. When you use true UTF-8, one would rather use the character rather than the entity, but some software, like phpBB2, saved certain entities within the data.
View user's profile Send private message Visit poster's website
unicornio
Involved
Involved


Joined: Aug 13, 2009
Posts: 432

PostPosted: Sun Apr 18, 2010 3:42 am Reply with quote Back to top

Hi montego, I did it with this script it was really easy. can you test the script in order to know if we need to change anything. The only problem with this script you need to download the files which contains the whole tables converted, if you dont do that then you wont be able to convert it. can u please help me a little bit to improve this script. Thanks for your explanation.
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sun Apr 18, 2010 3:21 pm Reply with quote Back to top

unicornio, actually, all my sites are in english so I am not able to assist with any kind of testing. Sorry.
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum