Hopefully a quick and obvious error on my part, I had a peek through previous questions but could not find question directly related to my question, so forgive me for opening what should be considered a fairly simple question, but after years of working with mysql the PDO switch is not coming easily
What I want to do
Simply insert entered form data to a new row of my table
Code
HTML
<form name="animals" id="animals" method="post">
<label for="animalType">Animal Type: </label>
<input type="text" required="required" name="animalType" />
<br />
<br />
<label for="animalName">Animal Name:</label>
<input type="text" required="required" name="animalName" />
<br />
<button type="submit" name="submit">Add</button>
</form>
PHP
if(isset($_POST['submit'])){
//here we get the data submitted in form and assign to vars
$type = $_POST['animalType'];
$name = $_POST['animalName'];
//here we are preparing our SQL statment
$sql = "INSERT INTO animals
(animal_type, animal_name)
VALUES
(?,?)";
//prepare DB as per above
$statement = $db->prepare($sql);
$statement->bindParam("ss", $type, $name);
$success = $statement->execute();
if($success){
echo'Welldone Chuck, Successfully Updated';
}
else{
$error = $db->error;
echo'Whoopsy Doopsy someone made a boopsy, ERROR INFO: $error';
}
$statement->close();
}
Error:
PDOStatement::bindParam() expects parameter 3 to be long, string given
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound'
Possible Reason For Error?
Dreamweaver as I am typing brings up a help function, as it often does (paramNo, Param, ParamType)
should I specify that I am binding 2 parameters here? (which I tried but same error as above though.)
Table
Thanks a million