0

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

2
Contributors
2
Replies
15
Views
3 Years
Discussion Span
Last Post by everton.retweets
0
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);

Or

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.

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.