-2

I created db_manager.php file.. i.e.

class db_manager
{
    function DBLogin() 
        {

        $this->connection = mysqli_connect("localhost","root","", "careerknots");

        if(!$this->connection)
        {               
            return false;
        }
        return true;
      }
    }

This is my upload_resume_action.php file.

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";
    }
}

I’m getting error in mysqli_query in first parameter. It is saying that it is expects parameter 1 to be mysqli, boolean.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Mohit
  • 57
  • 7
  • http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – user2182349 Dec 13 '15 at 06:13
  • `$con` is always a Boolean. You are returning either true or false in `DBLogin()`. Try returning the reference there. – Hecke29 Dec 13 '15 at 07:53

2 Answers2

1
  1. class db_manager not isset connect property

  2. method DBlogin return bool. Should return $this->connection

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Andrey
  • 441
  • 2
  • 7
-1

It worked after I replaced $con with $db_manager->connection in mysqli_query in upload_resume_action.php

Mohit
  • 57
  • 7