0

我有一个网站http://www.league.vivahosting.co.uk,它使用 Joomla 作为主要 cms 和 Dragonflycms 作为联赛组件模块。

现在我想要实现的是一个脚本,用于从jos_users表中复制用户名和电子邮件并将其插入cmsdf_users表中,现在每个表中的行如下

jos_users - username, email
cmsdf_users - username, user-email

现在我想对密码做同样的事情,但 joomal 的加密是哈希:我相信和 Dragonflycms 是 md5,所以我正在考虑一种解决方法,使用 joomla 提供的自定义字段来获得在传输过程中加密的纯 txt 密码从 db 到 db 的过程。

letnp_user现在自定义字段没有保存在 jos_users 表中,我相信它位于该表中user_id

以下是我到目前为止所拥有的

<?php

// Set the connection information
print $con = mysql_connect("localhost", "DBName", "Pass");

// Select the original database containing old records
print mysql_select_db("DBName", $con);

// Check the connection
if (!$con)
{
print die('Could not connect: ' . mysql_error());
}

// Select the records from the database
print $query = "SELECT * FROM letnp_users" or die(mysql_error());

// Run the query
print $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'];
    echo  $username;    
    $email = $row['email'];
    echo $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) VALUES ('$username', '$user_email')";


     // Run the INSERT query
    $insert = mysql_query
    ("
    INSERT INTO cmsdf_users(username,user_email)
    VALUES (NULL,'".$user."','".$user_email."')
    "); 


     // Check to make sure this particular INSERT worked
     if (!mysql_insert_id())
     {
          echo "ERROR: there was a problem inserting data.";
     }
}

// Close the connection
print mysql_close($con);

?>

但似乎不起作用,它给出了以下错误

Resource id #11SELECT * FROM letnp_usersResource id #2Cprl.Rstadmin@vivahosting.co.ukERROR: there was a problem inserting data.1
4

0 回答 0