0

我正在尝试从一个表中选择一个随机地址并将其添加到另一个表的其中一列中,但它一直说“未选择数据库”

if ($_SESSION[address] == "")
{
    $db = @mysql_select_db($db_bitcoins,$connection)
        or die(mysql_error());
    $sql = "SELECT Count(*) FROM address";
    $result = @mysql_query($sql, $connection) or die(mysql_error());
    $rnum = mysql_num_rows($result);
    $rrr=rand(1,rnum);
    $sql = "SELECT * FROM address WHERE id = '$rrr'";
    $result = @mysql_query($sql, $connection) or die(mysql_error());
    while ($sql = mysql_fetch_object($result)) {
        $_SESSION[address]  = $sql -> ads;
        $db = @mysql_select_db($db_name,$connection)
                        or die(mysql_error());
        $sql = "UPDATE $table_name SET bitaddress = $_SESSION[address] WHERE username = '$user' and password = password('$pass')";
        $result = @mysql_query($sql, $connection) or die(mysql_error());
    }
}

提前致谢!

4

2 回答 2

0

检查您是否正确提供了数据库名称(SID)、端口和主机 IP 以及数据库是否可访问(如果不在您的 PC 中)。

于 2012-04-17T11:38:21.360 回答
0

编辑:我发现 $db_bitcoins 没有设置,谢谢大家的帮助!"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"这次我又遇到了一个例外

于 2012-04-17T16:23:55.173 回答