HI there,
i have a website http://www.league.vivahosting.co.uk which uses Joomla for main cms and Dragonflycms as the league component module.
now what i want to achieve is a script to copy username and email from the jos_users table and insert it into the cmsdf_users table now the rows in each table are as follows
jos_users - username, email
cmsdf_users - username, user-email
now i’dlike to do the same with the passwords but joomal’s encryption is hash:salted i believe and Dragonflycms is md5 so i’m thinking a workaround using a custom field provided by joomla to have a plain txt password that is encrypted during the transfer process from db to db.
Now the custom field is not kept in the jos_users table its located in letnp_user which i believe are linked by user_id.
Below is what i have so far but doesn’t seem to work it gives the following error
ERROR: there was a problem inserting data.
and
[29-Aug-2012 15:31:13] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/leaguevi/public_html/convert.php on line 25
in toe error_log from the server.
[php]<?php
// Set the connection information
$con = mysql_connect(“localhost”, “DbName”, “Password”);
// Select the original database containing old records
mysql_select_db(“leaguevi_jooml62”, $con);
// Check the connection
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
// Select the records from the database
$query = “SELECT * FROM jos_users”;
// Run the query
$result = mysql_query($query);
// Now select the new database
mysql_select_db(“cmsdf_users”, $con);
// Loop through each row from the old database
while ($row = mysql_fetch_assoc($result))
{
// Set each column to a variable
$username = $row[‘username’];
$email = $row[‘email’];
// You could also reset defaults or check for NULL columns
// Here’s an example for permissions:
if ($row[‘permissions’] == 0)
{
$permissions = 1;
}
else if ($row[‘permissions’] > 3)
{
$permissions = $row[‘permissions’] + 1;
}
else
{
$permissions = $row[‘permissions’];
}
$date = $row[‘date’];
// Set up the INSERT query
$insert = "INSERT INTO cmsdf_users (username, user_email, permissions, date) VALUES ('$username', '$email', '$permissions', '$date')";
// Run the INSERT query
mysql_query($insert);
// Check to make sure this particular INSERT worked
if (!mysql_insert_id())
{
echo "ERROR: there was a problem inserting data.";
}
}
// Close the connection
mysql_close($con);
?>[/php]
Any help on this i would be very greatful