PDO bindparam not working.
Posted
by jim
on Stack Overflow
See other posts from Stack Overflow
or by jim
Published on 2010-04-06T02:21:26Z
Indexed on
2010/04/06
2:43 UTC
Read the original article
Hit count: 381
I am trying to save data into a database using PDO. All columns save correctly with the exception of one. No matter what I try, I cannot get the data to go in.
myfunc($db, $data) {
echo $data; // <----- Outputs my data. example: 'jim jones'
$stmt = $db->prepare("CALL test(:id, :data, :ip, :expires)");
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
$stmt->bindParam(':data', $data, PDO::PARAM_STR);
$stmt->bindParam(':ip', $ip, PDO::PARAM_STR);
$stmt->bindParam(':expires', $expires, PDO::PARAM_STR);
...
}
So even after verifying that the data variable in fact holds my data, the bindParam method will not bind.
When I echo the data variable, I can see the data is there. It will not save though. If I copy the echo'd output of the data variable to screen and paste it into a new variable, it WILL save.
I'm at this now for a couple of hours. Can someone please have a look?
EDIT: I want to also mention that I have tried using bindValue() in place of bindParam() and the data for the data variable will still not save.
© Stack Overflow or respective owner