我创建了db_manager.php文件..即
class db_manager
{
function DBLogin()
{
$this->connection = mysqli_connect("localhost","root","", "careerknots");
if(!$this->connection)
{
return false;
}
return true;
}
}
这是我的upload_resume_action.php
文件。
require_once("db_manager.php");
if(isset($_POST['submitted']))
{
$db_manager = new db_manager();
$con = $db_manager->DBLogin();
if(!$con)
{
echo "Database login failed!";
}
$cname = $_POST["uname"];
$cmob = $_POST["mob"];
$cemail = $_POST["email"];
$cfile = $_POST["myfile"];
$sql = "insert into res_detail(name,mobile,email,resume_loc) values ('$cname','$cmob','$cemail','$cfile')";
$done = mysqli_query($con,$sql);
if($done)
{
echo "records added successfully";
}
}
我在第一个参数的mysqli_query
中收到错误。据说它希望参数1是mysqli,boolean。
答案 0 :(得分:1)
类db_manager
未设置connect
属性
方法DBlogin
返回bool。应该返回$this->connection
答案 1 :(得分:-1)
我用$con
中的$db_manager->connection
中的mysqli_query
替换upload_resume_action.php