'PDO fetch me a fake result
I'm working on a function that compare two price.
I have a table called 'PRODUCT' that has 3 column: ID, REFERENCE, PRICE.
I get a price from a FORM that i will compare with the column PRICE. If the number that i get with the form, is different by PRICE from the table, i want get the REFERENCE. So i work in this way:
$pdo = new PDO ("mysql:host=$hostname;dbname=$dbname", $user, $pass);
$sql = "SELECT count(1) as NB
FROM ww_ps_product
WHERE reference = :reference AND SUBSTR(wholesale_price , 1, INSTR(wholesale_price ,'.')+2) != :price" ;
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':reference', **$referenza**, PDO::PARAM_STR);
$stmt->bindValue(':price', **$prezzoAggiornato**);
$stmt->execute();
$product = $stmt->fetch(PDO::FETCH_ASSOC);
The value that i get from the form : $referenza is FIN 260482300000 and the $prezzoAggiornato is 6.90 . Normalli, in my $product, i should have 0 but i get 1.
This data are store in DB with the same values:
When i go to compare with my function, i get NB = 1 but that's is impossible. If i check with the same values in phpMyAdmin i get NB = 0.
There is something wrong in my code?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

