-2

I want to insert password to the database existing field.but this shows an error..

 <?php
    include './DB_Connection/connection.php';
    //some code
    $sql = mysql_query("UPDATE user_info SET password = '$password' WHERE company_name='$company_name' AND email = '$email' ");
            $result = $db->query($sql);
            echo 'out';
            if ($result) {//some cose
       }
    ?>

Fatal error: Call to a member function query() on a non-object in "path"\password_generation.php on line 23

line 23 is : $result = $db->query($sql);

Smita Ahinave
  • 1,901
  • 7
  • 23
  • 42
saku
  • 193
  • 3
  • 14

2 Answers2

1
  <?php
include './DB_Connection/connection.php';
//some code
 $sql = "UPDATE user_info ". "SET password = $password ". 
           "WHERE company_name = $company_name AND email= $email";
     $result=  mysql_query($sql)
      //  $result = $db->query($sql);
        echo 'out';
        if ($result) {//some cose
   }
?>
Anish Rai
  • 698
  • 9
  • 16
0

remove 'mysql_query' function, $db->query() should get a string. and mysql_query is already deprecated in 5.5

Tim
  • 380
  • 2
  • 8