A MySQL error occurred.\n
Query: " . $sql . "
\nError: (" . mysql_errno() . ") " . mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$member_id = $row["member_id"];
$password = $row["pn_pass"];
echo 'Updating password for member ID: ' . $member_id . '
';
$sql2 = "UPDATE exp_members
SET password='$password'
WHERE member_id=$member_id";
mysql_query($sql2,$connection)
or die ("A fatal MySQL error occurred.\n
Query: " . $sql2 . "
\nError: (" . mysql_errno() . ") " . mysql_error());
}
mysql_free_result($sql_result);
// -------------------------------------------------------------------
// Since I ran this periodically as the go live date approached, I only
// really want to bring over members who have registered since the
// last time. To do that we need identify the last member ID that was
// imported and start after that.
// -------------------------------------------------------------------
$sql = "SELECT MAX(member_id)
FROM exp_members";
$sql_result = mysql_query($sql,$connection)
or die ("A MySQL error occurred.\n
Query: " . $sql . "
\nError: (" . mysql_errno() . ") " . mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$last_id = $row["MAX(member_id)"];
echo 'Import users starting after member ID: ' . $last_id . '
';
}
mysql_free_result($sql_result);
// -------------------------------------------------------------------
// Now we can pull the info we want from the PN user table, set default
// values, create our unique IDs, and insert it all into EE
// -------------------------------------------------------------------
$sql = "SELECT pn_uid, pn_uname, pn_pass, pn_email, pn_user_from, pn_user_occ, pn_user_intrest, pn_user_regdate
FROM nuke_users
WHERE pn_uid > $last_id";
$sql_result = mysql_query($sql,$connection)
or die ("A MySQL error occurred.\n
Query: " . $sql . "
\nError: (" . mysql_errno() . ") " . mysql_error());
while ($row = mysql_fetch_array($sql_result))
{
$member_id = $row["pn_uid"];
$group_id = 4; // Default to pending, then set where desired manually in EE
$username = addslashes($row["pn_uname"]);
$screen_name = addslashes($row["pn_uname"]);
$password = $row["pn_pass"];
$unique_id = unique_hex();
$email = $row["pn_email"];
$location = addslashes($row["pn_user_from"]);
$occupation = addslashes($row["pn_user_occ"]);
$interests = addslashes($row["pn_user_intrest"]);
$join_date = $row["pn_user_regdate"];
$last_visit = $join_date;
$language = 'english';
$timezone = 'UM5';
$cp_theme = 'default';
echo 'Importing member ID: ' . $member_id . '
';
$sql2 = "INSERT INTO exp_members (member_id, group_id, username, screen_name, password, unique_id, email, location,
occupation, interests, join_date, last_visit, language, timezone, cp_theme)
VALUES ('$member_id', '$group_id', '$username', '$screen_name', '$password', '$unique_id', '$email', '$location',
'$occupation', '$interests', '$join_date', '$last_visit', '$language', '$timezone', '$cp_theme')";
mysql_query($sql2,$connection)
or die ("A fatal MySQL error occurred.\n
Query: " . $sql2 . "
\nError: (" . mysql_errno() . ") " . mysql_error());
$sql2 = "INSERT INTO exp_member_data (member_id)
VALUES ('$member_id')";
mysql_query($sql2,$connection)
or die ("A fatal MySQL error occurred.\n
Query: " . $sql2 . "
\nError: (" . mysql_errno() . ") " . mysql_error());
$sql2 = "INSERT INTO exp_member_homepage (member_id)
VALUES ('$member_id')";
mysql_query($sql2,$connection)
or die ("A fatal MySQL error occurred.\n
Query: " . $sql2 . "
\nError: (" . mysql_errno() . ") " . mysql_error());
}
mysql_free_result($sql_result);
// -------------------------------------------------------------------
// Close connection
// -------------------------------------------------------------------
mysql_close($connection);
// -------------------------------------------------------------------
// A final note: This will NOT work for anyone else without some
// adjustments. Also, did not play around with automating the groups
// since I only have about 20 who are not in the standard members
// group, and the security setup is quite different in PN. Even so,
// it shouldn't be all that hard for someone to add it in.
// -------------------------------------------------------------------
?>