Script to Migrate PHPNuke to Drupal - UTF8 to UTF8

Category:

Update (Feb 25, 08): New Version 0.04w that included 2 lines of code below can be downloaded -> HERE .

I need to port a website in PHPNuke 7.8 to Drupal 5.7. I've searched all over and found a script to do that from this website. The latest version on that website is 0.02w. The script works great but with a problem, the language that is not English didn't import correctly. All those non-english characters show as "?" So, that imported data can't be used.

Then, I continue looking for more information and found a newer version which is 0.03w from this website. This newer version gave me the same problem.

I, then, looked into the script, checked my database. I found that the data on my temporary PHPNuke database is UTF8. (It has been converted when I imported into MySQL.) So, what I need to do is to import data from UTF8 to UTF8. The migration script didn't write to do that. So, I put these two lines into the script line 280 (in Migration Script version 0.03w) :

$result = mysql_query("SET NAMES utf8", $link);
$result = mysql_query("SET CHARACTER SET utf8", $link);

The script near line 280 (With 2 more lines of code) will look like below :

	//Connect to MySQL
	$connected = true;
	$link = @mysql_connect($host, $username, $password);
	if (!$link)
	{
		failure("Connection to MySQL could not be made. Edit this file and make sure that the database settings are correct.");
		echo " Error returned by MySQL (if any): (" . mysql_errno() . ") " . mysql_error() . " \n";
		$connected = false;
		if (isset($_GET["section"]))
		{
			exit();
		}
	}
	$result = mysql_query("SET NAMES utf8", $link);
	$result = mysql_query("SET CHARACTER SET utf8", $link);
	
	// if you have php5 and the "tidy" module, this will clean up user text for you.
	function tidyhtml($str)
	{

Test the migration script and it works perfectly now.

Note 1: You can convert MySQL data in PHPNuke to UTF8 using import feature under phpMyAdmin. (When import, select "Character set of the file" to what it original is.) After imported, those data will be UTF8. Then, use script with 2 more lines above to convert data to Drupal.

Note 2: My tested computer runs on Windows XP with the following software installed
     - phpMyAdmin 2.11.0
     - MySQL 5.0.45
     - Apache 2.2
     - PHP 5.2.4

Note 3: What I did is to import users and stories, not forum or anything else. That means I didn't test the script if it works with those functions or not.

Comments

thanks, I updated the script to version 0.04. If you want to be properly credited - please send me the data to include into the script history portion.

I'm ok with what you put in history portion. I'm glad what I did is useful :)

I tested it importing forums and it works! Thanks for your help

Glad it works for you :)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.