我正在尝试编写选择、连接和访问数据库的代码,但不工作:X
$mysql_storage = true;
if($mysql_storage){
$databases = array(
array("localhost","glibet_login","#####","glibet_site")
);
foreach($databases as $database){
$makeconnection = $database[1];
${$makeconnection} = mysql_connect($database[0],$database[1],$database[2]);
mysql_select_db($database[3], $database[1]);
}
}
$query = "SELECT * FROM users WHERE email='marsalcorreialima@gmail.com'";
$littlequery = mysql_query($query, $glibet_login);
$littlefetch = mysql_num_rows($littlequery);
print $littlefetch;
请告诉我这段代码是否至少有意义
警告:mysql_select_db() 期望参数 2 是资源,字符串在第 16 行的 /home/glibet/public_html/api/api_storage.php 中给出
编辑[已解决]!
mysql_select_db($database[3], ${$makeconnection});