我正在尝试从一个表中选择一个随机地址并将其添加到另一个表中的一个列上,但它一直说“没有选择数据库”
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());
}
}
提前致谢!
答案 0 :(得分:0)
检查您是否正确提供了数据库名称(SID),端口和主机IP,并且数据库是否可访问(如果不在您的PC中)。
答案 1 :(得分:0)
"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"