我有将记录从一个数据库复制到另一个数据库的代码。
以下代码适用于我的本地测试服务器(WAMP),但当我在实时服务器(1&1)上运行时,会出现错误“错误:SELECT command denied to user 'dbo123456'@'localhost' for table 'names'”
$con1 = mysql_connect( HOST1 , USER1 , PASS1 , "db1" );
if (!$con1)
{
echo "Failed to connect to db1 " . mysqli_connect_error();
}
$con2 = mysql_connect( HOST2 , USER2 , PASS2 , "db2" );
if (!$con2)
{
echo "Failed to connect to db2 " . mysqli_connect_error();
}
$sql = "
INSERT INTO db2.names ( title , surname )
SELECT title , surname
FROM db1.names
WHERE nameID = 1
";
$result = mysql_query( $sql );
if (!$result) {
die('Error: ' . mysql_error());
}
我以前从未使用过多个数据库,也无法弄清楚可能出了什么问题。这只是 1&1 的事情还是我做错了?