fran Posted March 26, 2011 Share Posted March 26, 2011 I am trying to update a db with "lastname, firstname". When I use the comma, it deletes everything after the comma. I tried replacing the comma with a special character but it didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 It's more likely that your HTML is invalid somewhere and is not showing you the whole value. Have you looked directly in your database table using your favorite database management tool (i.e. phpmyadmin) so that you know what exactly is being stored in the table? Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192556 Share on other sites More sharing options...
fran Posted March 26, 2011 Author Share Posted March 26, 2011 I even put lastname, firstname into the MySql db and then tried to update it. It then changes it to lastname, and deletes the rest. Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192560 Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 That would be a logical problem with your code and you would need to post your code if you want specific help with it. Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192578 Share on other sites More sharing options...
fran Posted March 26, 2011 Author Share Posted March 26, 2011 Database has Artist: "lastname, firstname" Text is sent from here: $sql = "SELECT DISTINCT Artist FROM inventory ORDER BY Artist"; <option value=$row[Artist]>$row[Artist]</option> Updated here: $sql = "UPDATE inventory SET id = '$id', Title = '$_POST[Title]', Artist = '$artist', ... I have mysql error on both but no errors appear. It simply eliminates everything after the comma and saves in database "lastname," Is that enough to give you an idea? Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192582 Share on other sites More sharing options...
Pikachu2000 Posted March 26, 2011 Share Posted March 26, 2011 As PFMaBiSmAd already mentioned, your HTML markup is invalid. value= attributes need to be quoted or the value will be truncated at the first space encountered. Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192588 Share on other sites More sharing options...
fran Posted March 26, 2011 Author Share Posted March 26, 2011 Oh, now I understand. I needed <option value="lastname, firstname">... <option value="<? echo "$row[Artist]"; ?>"><? echo "$row[Artist]"; ?></option> Now it works! Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/231785-input-text-with-commas/#findComment-1192593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.