I'm trying to save the following string to the database: 12E2
. Because of the E
(exponent) MySQL is saving it as "1200" (12 × 102). Is there any way to avoid this? I'm trying to save it to a VARCHAR
field in the database.
$q->bindValue(":field","12E2",PDO::PARAM_STR);
Edit: I've uploaded a script which shows the case. The script uses the following code:
$fetchQuery=$db->prepare("SELECT `strLocatieNr` FROM `tblShopProducten` WHERE `intID`=254");
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo "Old: ".$fetchData["strLocatieNr"]."<br />";
$updateValue=@$_GET["value"];
echo "Update value: ";
var_dump($updateValue);
echo "<br />";
$q=$db->prepare("UPDATE `tblShopProducten` SET `strLocatieNr`=:field WHERE `intID`=254");
$q->bindValue(":field",$updateValue,PDO::PARAM_STR);
$q->execute();
echo "Rows affected: ".$q->rowCount()."<br />";
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo "New: ".$fetchData["strLocatieNr"];
Odd, I cannot reproduce it. Are you sure the field type in the database is varchar(x) where x is the maximum desired length of a string?
Alternatively, are you sure your bind value is surrounded by quotes in the actual code?
If nothing works I'd give a shot to this
$q->bindValue(":field",(string)"12E2",PDO::PARAM_STR);