0

I had a problem when making the insert function with bindParam or bindValue, always error like this: enter image description here

what should be improved from my code :

<?php

function IUD($sql, $param = array()){ 

global $koneksi;

$stmt = $koneksi->prepare($sql);

foreach ($param as $key => $value) {
if(is_int($value)){
$stmt->bindParam("$key", $value, PDO::PARAM_INT);
}else{
$stmt->bindParam("$key", $value);
}
}

$ret = $stmt->execute();
}

$insert = IUD("INSERT INTO user (nama_lengkap,username,password,type_user,foto,tgl) VALUES(:nm,:user,:pass,:type,:foto,:tgl)", array(':nm'=>$nm,':user'=>$user,'pass:'=>$pass,':type'=>$type,':foto'=>$foto,'tgl'=>$tgl));

?>
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
FadLy
  • 107
  • 1
  • 9

1 Answers1

0

You had a typo, that's all. You should have:

':tgl' => $tgl

In your query $params array.

Darren
  • 13,050
  • 4
  • 41
  • 79