Sleeper Posted March 18, 2012 Share Posted March 18, 2012 I need a way to keep entrys into a database from being doubled. The issue is that on something like %7B%7D that is the same as {} in html. So if one is entered in with the percentages and one is entered in normal, the data base thinks they are two different items even though they could be the exact same thing. Now when I insert the new item into the data base the value ='s mysql_real_escape_string(htmlentities(item)) is how I do it now. This is wrong im guessing cause it could go with either of the above examples and puts them in as given. So my question here is kinda two parted. 1) how do I get it to insert the info one way or the other but never both being allowed. So {} will always show %7B%7D when inserted or visa versa. and 2) How do I take an existing database and sort threw it to make sure they are all the same as 1 codes the new ones in, and take out any possible dupilications due to the difference? Quote Link to comment https://forums.phpfreaks.com/topic/259222-how-to-stop-duplicates/ Share on other sites More sharing options...
Sleeper Posted March 19, 2012 Author Share Posted March 19, 2012 I would of thought that this could be an easy fix. A bit shocked no one has responded to this yet. Quote Link to comment https://forums.phpfreaks.com/topic/259222-how-to-stop-duplicates/#findComment-1329123 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 1 - your best solution would be to use a regular expression replacement on your inputs. 2 - run updates replacing all instances of one with another. Quote Link to comment https://forums.phpfreaks.com/topic/259222-how-to-stop-duplicates/#findComment-1329132 Share on other sites More sharing options...
Sleeper Posted March 21, 2012 Author Share Posted March 21, 2012 I am not sure what you mean by either answer. I am still pretty new to most of the php sql things as I teach my self as I go on what I need. So could you be a bit more specific and show an example of what you mean please. Quote Link to comment https://forums.phpfreaks.com/topic/259222-how-to-stop-duplicates/#findComment-1329910 Share on other sites More sharing options...
Muddy_Funster Posted March 22, 2012 Share Posted March 22, 2012 there is a whole subtopic on this board for Regex, look through that for the regular expression stuff, it's way to big a topic to sum up in a quick post, as for the update, just run something against the database that replaces the vaules in all the fields that contain the value you want rid of. Again, it's a little too vauge, but it depends on your table structure and field types. I think there was someone on the MySQL forum that had a simmilar question last week. Quote Link to comment https://forums.phpfreaks.com/topic/259222-how-to-stop-duplicates/#findComment-1330127 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.