| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 65989 | 2006-02-07 05:28:00 | PHP Update problem with "-" symbol | Morgenmuffel (187) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 427907 | 2006-02-07 05:28:00 | Hi all A number is being returned as "454776-01" (which is correct) and when I echo the number out it echos out as "454776-01", BUT when i write it to the database it gets written in as "454776" everything after the "-" symbol is lost and I can't work out how to prevent it losing the data the field in the database is a varchar(50) so that shouldn't be a problem If i can echo out the returned number, then i should be able to write it to the database shouldn't I? $bob = $ti; echo $bob.'<br>'; this echos out as 454776-01 mysql_query("update a_orders set error_code = ".$ec.", transaction_Id = ".$bob." where order_Id = '".$merchant_ref."' AND merchant_session = '".$ms."'"); Thanks |
Morgenmuffel (187) | ||
| 427908 | 2006-02-07 05:57:00 | Doesn't transaction_Id's value $bob need to be quoted as well just like you do in the ... where order_Id = '".$merchant_ref."' part?? Otherwise MySQL is thinking it is a number of sorts. I'd just write code like: $sql = "update a_orders set error_code = ".$ec.", transaction_Id = ".$bob." where order_Id = '".$merchant_ref."' AND merchant_session = '".$ms."'"; and echo that to what sql query that MySQL is getting. You want to quote with a function like this (nz.php.net) . Or use PEAR DB abstraction layer or something. |
gibler (49) | ||
| 427909 | 2006-02-07 09:37:00 | Doesn't transaction_Id's value $bob need to be quoted as well just like you do in the ...where order_Id = '".$merchant_ref."' part?? Otherwise MySQL is thinking it is a number of sorts. Exactly right Thanks Gibler this is the second time in as many days as i have missed the obvious, thank god the school holidays finish tomorrow, i'll be able to work without bored kids, tv and the barbie website chattering on in one ear |
Morgenmuffel (187) | ||
| 1 | |||||