0

there are 6 columns in my database table. But, I only want to update 3 columns. I am trying this code.

$stmt = $this->conn->prepare("UPDATE users SET name=?, class=?, subject=? WHERE id=?");

        $name = $data['name'];
        $class = $data['class'];
        $subject = $data['subject'];

        // Binding the params to the stmt object
        $stmt->bind_param("user", $name, $class, $subject);

        // Execute the prepared statement
        $response = $stmt->execute();
        $stmt->close();
        return $response;

which is not working. Record is not updating. keeps showing empty page. No response is coming after execution.

Naina
  • 11
  • 2
  • where is the SQL? – Honk der Hase May 23 '20 at 10:36
  • `bind_param()` is wrong. I'll find a duplicate. The first param needs to be 4 characters but "user" isn't right; it is more likely to be "sssi". Assuming those types are correct, you will need `$stmt->bind_param("sssi", $data['name'], $data['class'], $data['subject'], $id);` No need to redeclare the variables. Next time you post a question, please include the generated errors. – mickmackusa May 23 '20 at 10:40

0 Answers0