limitphp Posted April 22, 2009 Share Posted April 22, 2009 I have links that have artistName and songName in them. Right now I have a column that has artistNameHash and songNameHash and those are what I use for the links. ex) mysite.com/comments/$artistNameHash/$songNameHash when I add the artists and songs to the database, thats when i manually add the songNameHash and artistNameHash.....there are no set rules I use.... so far I'm replacing spaces with dashes and single quotes with underscores....I haven't had any other symbols yet...because I'm just using test songs so far. so, my mod rewrite handles underscores and dashes..... I'm thinking I should change it to handle it like this: add the song name and artist name to the database when I add the song. Don't worry about adding a songNameHash and artistnameHash column to my database. When I need to link using the songName and artistName, run both through the urlencode and use that: ex) $url_artistName = urlencode($artistname); $url_songname = urlencode($songName); mysite.com/comments/$url_artistName/$url_songName/ and then, fix the mod rewrite to accept all the characters urlencode throws at it. When the request comes in: $artistName = $_GET('artistName'); it'll get converted back automatically into the original artistname, correct? does this sound like the better way to do it? thanks Quote Link to comment https://forums.phpfreaks.com/topic/155244-best-practice-way-to-handle-url-encodes/ Share on other sites More sharing options...
limitphp Posted April 23, 2009 Author Share Posted April 23, 2009 what this make storing hash names obsolete? Quote Link to comment https://forums.phpfreaks.com/topic/155244-best-practice-way-to-handle-url-encodes/#findComment-817332 Share on other sites More sharing options...
laffin Posted April 23, 2009 Share Posted April 23, 2009 I prefrt using the id, since almost all tables have a id INT(11) AUTO_INCREMENT field. But yeah, why make a id/hash system if ya dun use em Quote Link to comment https://forums.phpfreaks.com/topic/155244-best-practice-way-to-handle-url-encodes/#findComment-817383 Share on other sites More sharing options...
limitphp Posted April 23, 2009 Author Share Posted April 23, 2009 I prefrt using the id, since almost all tables have a id INT(11) AUTO_INCREMENT field. But yeah, why make a id/hash system if ya dun use em I would assume to not use the id, since we want the site to be SEO friendly. The hash names were going to be used to fix the artistName and songName to make them ok for url.... but I figure why enter in each hash name manually, when urlencode will take care of the problem for you? the only thing is, the percent and urlencode might mess up the adobe mod rewrite..... Quote Link to comment https://forums.phpfreaks.com/topic/155244-best-practice-way-to-handle-url-encodes/#findComment-817491 Share on other sites More sharing options...
laffin Posted April 23, 2009 Share Posted April 23, 2009 urlencode wnt mess with apache mod rewrite but u shud also be using urldecode urlencode makes GET parameters safe for address url usage. Quote Link to comment https://forums.phpfreaks.com/topic/155244-best-practice-way-to-handle-url-encodes/#findComment-817631 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.