Hi, I just want to ask some help on this PDO, i am inserting record in my table using PDO.What i want is to echo if i have successfully inserted or echo Failed.
I tried to change the variable $age to $ages so that it will print Failed in insert,but it did not perform the else statment,can you help me please how can i determine if i have succesfully inserted or Failed in insert.
Hi cups, No data is inserted because it has an error of variable $ages it should be $age…but what i want is to execute else statement if there is an error…i also tried to insert properly but what happened is that it will insert repeatedly i mean 2 rows will be inserted with the same data…I read in the php manual that PDO::execute() will return values true and false. I think the execute will not return anything…I am confuse on this.can you help me please.
$query ->execute(array($fname,$lname,$age));
// do this to see what query is returning exactly
var_dump($query);
if($query)
echo "Successfully Inserted";
else
echo "Failed in insert";