Skip to content
Advertisement

Variable is dump to database but the data is not updated? [closed]

By using var_dump($_POST), I get this:

array(2) { [“leadershipr”]=> string(1) “2” [“add”]=> string(0) “” } 4

But, data inside the database is not updated.

This is my code for data update,

if(isset($_POST['add']))
{

$id = $_GET['id']; //GET ID

$leadershipr=$_POST['leadershipr'];

$sql = "UPDATE 360feedback SET leadershipr=:leadershipr WHERE id=:id";

$query = $dbh->prepare($sql);
$query->bindParam(":leadershipr",$leadershipr,PDO::PARAM_STR);
$query->execute();

echo $id;
}

Advertisement

Answer

It seems like you forgot to bind your ‘id’ parameter?

Maybe add in the following (after the first bindParam and before the execute call):

$query->bindParam(":id",$id, PDO::PARAM_INT);
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement