kirkheaton25
asked on
PHP PDO Insert Error
I am trying to insert data into a mysql database using PDO. The code is:
however, I am getting the following error:
Thanks.
$query = "INSERT INTO `Staff` (`email`, `fullname`, `mobile`, `telephone`, `work-phone`, `faddress`, `postcode`, `marital`, `children`, `dob`, `hobbies`, `health`, `gid`, `cv`, `wages`, `employment`)
VALUES
(:email, :fullname, :mobile, :telephone, :work-phone, :faddress, :postcode, :marital, :children, :dob, :hobbies, :health, :gid, :cv, :wages, :employment)";
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$q = $dbh->prepare($query);
$insert = array(':email'=>$contact,
':fullname' => $fullname,
':mobile' => $mofo,
':telephone' => $telephone,
':work-phone' => $workTelephone,
':faddress' => $faddress,
':postcode' => $pc,
':marital' => $ms,
':children' => $children,
':dob' => $dob,
':hobbies' => $hobbies,
':health' => $health,
':gid' => $gid,
':cv' => $cv,
':wages' => $wages,
':employment' => $empl);
$q->execute($insert);
however, I am getting the following error:
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined on line 67I'm new to PDO so could someone please tell me what the problem is here.
SQLSTATE[HY093]: Invalid parameter number on line 67
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No other answers provided resolution or pointed me towards the resolution.
I have used this syntax, and it works for me -
$stmt = $dbo->prepare('INSERT INTO authors (author,csvId) VALUES (:aut,:csvId)');
$params = array(':aut'=>$auth,':csvI
$stmt->execute($params);