grlayouts Posted March 3, 2011 Share Posted March 3, 2011 i have a cell in my database like Stats 100-10-3 and i want to update that with my code $details = 100 . '-' . 10 . '-' . 3; $sql = "UPDATE usertable SET uSkillsMax=$details"; but my database updates instead of 100-10-3 it says 87? which is doing the math? any way to fix this? Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/ Share on other sites More sharing options...
litebearer Posted March 3, 2011 Share Posted March 3, 2011 http://stackoverflow.com/questions/1035634/converting-int-to-string-in-php Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182484 Share on other sites More sharing options...
grlayouts Posted March 3, 2011 Author Share Posted March 3, 2011 i dont get it? Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182485 Share on other sites More sharing options...
cunoodle2 Posted March 3, 2011 Share Posted March 3, 2011 Few things.. 1) Look into your database. What "type" of field is "uSkillsMax"? Is it an "int"? If so change it to a "VARCHAR" 2) In this line you have the numbers listed so they are technically integers... $details = 100 . '-' . 10 . '-' . 3; Instead do this.. $details = strval(100)."-".strval(10)."-".strval(3); OR this.. $details = "100"."-"."10"."-"."3"; Try those out and let me know what you come up with Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182486 Share on other sites More sharing options...
PFMaBiSmAd Posted March 3, 2011 Share Posted March 3, 2011 $details is a string and string data must be enclosed in single-quotes in a query, otherwise your string looks like a mathematical expression. $sql = "UPDATE usertable SET uSkillsMax='$details'"; Edit: Don't make this harder than it really is. Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182487 Share on other sites More sharing options...
cunoodle2 Posted March 3, 2011 Share Posted March 3, 2011 http://stackoverflow.com/questions/1035634/converting-int-to-string-in-php i dont get it? I love how user "litebearer" takes the time to post you a link and if you look at the difference between his post time and that of the OP (grlayouts) he spent all of 1 minute 44 seconds looking at the link provided by litebearer only to quickly respond with a "i dont get it?" Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182489 Share on other sites More sharing options...
grlayouts Posted March 3, 2011 Author Share Posted March 3, 2011 thanks PFMaBiSmAd and cunoodle2, litebearer im not really that good with php to understand any of the code you provided, but thanks for trying to help.. Link to comment https://forums.phpfreaks.com/topic/229513-simple-query/#findComment-1182495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.