我想在类中加载配置文件.这是config.php的内容
$__error_reporting_level=1;
$server='localhost';
$user='root';
$password='';
$dbase='eauction';
?>
sql.php的内容
include ('config.php');
error_reporting($__error_reporting_level);
class sql
{
function connect()
{
$connections = mysql_connect($server, $user,$password) or die ('Unabale to connect to the database');
mysql_select_db($dbase) or die ('Unable to select database!');
return;
}
function login($email, $pwd)
{
$this->connect();
$result = $this->qry("SELECT uid,nameF FROM user WHERE email='".$email."' AND password='".$pwd."'");
$row=mysql_fetch_array($result);
if (mysql_num_rows($result)>0)
return array($row[0],$row[1]);
else
return array(0,0);
}
}
?>
我使用执行代码
include ('core/sql.php');
$obj = new sql;
$data=$obj->login($email,$pwd);
print_r($data);
我收到这个错误
无法选择数据库!
忽略mysql注入问题,我只需要完美地执行代码