Reputation: 45
Following problem:
If I want to search with 'Last Name' it works but if it is a variable in this form $results['22']['BuyerName2']
Here is what I got so far:
$rr=$results[22]['BuyerName2'];
echo $rr; //echos Last Name
$stmt = $db->prepare("Update base_1 SET UpdateStatus=2 WHERE BuyerName LIKE ?");
$stmt->bindValue(1, "%$rr%", PDO::PARAM_STR);
$stmt->execute();
If I put instead $rr
the Name directly in the bind value part it works. But not with $rr
.
Upvotes: 0
Views: 60
Reputation: 528
In the line:
$stmt->bindValue(1, "%$rr%", PDO::PARAM_STR);
I am unsure whether the $ becomes escaped or not in the string you binded. As far as I know, only the underscore and the percent sign stay unescaped. I would suggest to try:
$rr = "%".$rr."%";
and edit the line to:
$stmt->bindValue(1, $rr, PDO::PARAM_STR);
Upvotes: 1
Reputation: 780994
Maybe there are extra spaces in $rr
. Try:
$rr = trim($results[22]['BuyerName2']);
Upvotes: 3