Hi, I am trying to update a simple mysql query using PHP PDO
The simple query read

$query = mysql_query("SELECT * FROM tbl_name WHERE oauth_provider = 'twitter' AND oauth_uid = ". $user_info->id);

My PHP PDO query reads

$STM = $dbh->prepare('SELECT * FROM tbl_name WHERE oauth_provider = :op AND oauth_uid = :ou');
$STM->bindParam(':op', twitter, PDO::PARAM_STR, ':ou', $user_info->id, PDO::PARAM_INT);

But I keep getting the following error, Not sure how to get round it,
Fatal error: Cannot pass parameter 2 by reference

Thanks in advance

Member Avatar


bindParam(':op', twitter, PDO::PARAM_STR, ':ou', $user_info->id, PDO::PARAM_INT);

This is mashed. You can either do one parameter at a time or pass an array to execute().

$STM->bindParam(":op", "twitter", PDO::PARAM_STR);
$STM->bindParam(":ou", $user_info->id, PDO::PARAM_INT);


execute(array(":op"=>"twitter", ":ou"=>$user_info->id));

btw you tried to pass twitter as a parameter - unless this is an actual constant, you'll get an error. I'm assuming you wanted to pass a string here, so enclose it in quotes.