hessie Posted March 19, 2003 Share Posted March 19, 2003 Hi all, when I read a table, edit a value and want to write that back to the table in another field, there goes something wrong when the selected field contains \"123456789AB\". However \"123456\" goes alright. $data_res = db_query("SELECT number, number2 FROM item") or db_die(); while ($data_row = db_fetch_row($data_res)) { $string2 = $data_row[0]; $string2 = str_replace(".", "", $string2); $result=db_query("update item set number2=$string2 where number=$data_row[0]") or db_die(); if ($result) {echo "Article $data_row[0] with new $string2 is updated";} else {echo "-- > Article $data_row[0] with new $string2 is not updated";} echo "<BR>"; } I fetch the value \"1234.5678AA\", this result in $string2 as \"12345678AA\" but MySql gives an error \"There is something wring in the used syntax at \'AA\' in row 1\". :? When I fetch a value of \"1234.5678\", $string2 will result with \"12345678\" and the update goes fine. The details of \'number2\' field is text. Please HELP!!!! thanks, Henk. Link to comment https://forums.phpfreaks.com/topic/238-update-problem-with-numbers-and-text/ Share on other sites More sharing options...
ystrigathe Posted March 19, 2003 Share Posted March 19, 2003 just try it with \'\': update item set number2=\'$string2\' where ... Link to comment https://forums.phpfreaks.com/topic/238-update-problem-with-numbers-and-text/#findComment-715 Share on other sites More sharing options...
hessie Posted March 20, 2003 Author Share Posted March 20, 2003 just try it with \'\': update item set number2=\'$string2\' where ... Thanks.... But i tried it with \'\".$string2.\"\' and \'$string2\' etc.... Unfort. no dice. Field is a VARCHAR of 16 of length. Any other ideas? THANKS! Link to comment https://forums.phpfreaks.com/topic/238-update-problem-with-numbers-and-text/#findComment-720 Share on other sites More sharing options...
hessie Posted March 20, 2003 Author Share Posted March 20, 2003 just try it with \'\': update item set number2=\'$string2\' where ... Thanks.... But i tried it with \'\".$string2.\"\' and \'$string2\' etc.... Unfort. no dice. Field is a VARCHAR of 16 of length. Any other ideas? THANKS! I found it.... when i use this CHAR(\'$string2\') for every field, it works. I still have an issue, that my data is not being updated.... When I find a solution, i also post it here.... When someone has a solution, i hope you can reply this mesage. Thanks in advance.... Link to comment https://forums.phpfreaks.com/topic/238-update-problem-with-numbers-and-text/#findComment-721 Share on other sites More sharing options...
hessie Posted March 20, 2003 Author Share Posted March 20, 2003 just try it with \'\': update item set number2=\'$string2\' where ... Thanks.... But i tried it with \'\".$string2.\"\' and \'$string2\' etc.... Unfort. no dice. Field is a VARCHAR of 16 of length. Any other ideas? THANKS! I found it.... when i use this CHAR(\'$string2\') for every field, it works. .... Weird.... Now your solution works... finally. THANKS! I found out, that CHAR() and ASCII() returns the sum of char values.... logical...I had to remember that when i developed in C years ago... It works!!!! Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/238-update-problem-with-numbers-and-text/#findComment-722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.