$txtmemberid = $_POST['txtmemberid'];
$txtname = $_POST['txtname'];
$txtphoneno = $_POST['txtphoneno'];
$txtmembertype = $_POST['txtmembertype'];
$query = "insert into member(member_id, name, ph_no, member_type) values(:member_id, :name, :ph_no, :member_type)";
try{
$stmt = $conn -> prepare($query);
$stmt -> bindParam(':member_id', $txtmemberid);
$stmt -> bindParam(': name', $txtname);
$stmt -> bindParam(':ph_no', $txtphoneno);
$stmt -> bindParam(':member_type', $txtmembertype);
$stmt -> execute();
}
Asked
Active
Viewed 32 times
-4

Your Common Sense
- 156,878
- 40
- 214
- 345

Nauman Rehmat
- 1
- 3
-
There's a pretty obvious typo on the second call to `bindParam`... – David Dec 20 '15 at 12:47
-
Does this answer your question? [SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined](https://stackoverflow.com/questions/5874383/sqlstatehy093-invalid-parameter-number-parameter-was-not-defined) – Your Common Sense Jan 28 '23 at 12:27
1 Answers
1
Your problem is more than likely on this line:
$stmt -> bindParam(': name',$txtname);
You have extraneous whitespace between :
and name
, change it to this:
$stmt -> bindParam(':name',$txtname);

tddmonkey
- 20,798
- 10
- 58
- 67