how to pass an associative array into php functions? i tried the code below but its not working. please help me or atleast give advice. thank you so much.
addrecord.php
require 'class.php';
$fields = array(
'strname' =>$name,
'strdescript' =>$strdescript,
'straction' =>$straction
);
$addRecord = new Record();
$addRecord->addRecord($fields);
class.php
class Record{
public $db, $sql,$stmt;
public function __construct(){
$this->db = new connection();
$this->db = $this->db->dbConnect();
}
public function addRecord($fields){
$this->sql =
"INSERT INTO user
(name,description,action)
VALUES
(?,?,?)"
$this->stmt = $this->db->prepare($this->sql);
$this->stmt->bindParam(1,{$fields['strname']},PDO::PARAM_STR);
$this->stmt->bindParam(2,{$fields['strdescript']},PDO::PARAM_STR);
$this->stmt->bindParam(3,{$fields['straction']},PDO::PARAM_STR);
$this->stmt->execute();
if($this->stmt->rowCount==1){
echo "<script>alert('blah.. blah.. blah.')</script>";
}else{
echo "<script>alert('blah.. blah.. blah.')</script>";
}//EndIf
}//EndFunction