I'm trying to set up a php page that pulls an album title from a url parameter where the title has its spaces stripped and replaced with dashes i.e. /reviews/foo-bar when the title is foo bar. going to use modrewrite to point that to a page that will pull the foo-bar out of the url as a parameter and hopefully pull the corresponding review for foo bar album. I can't seem to get it to pull correctly, I've tried using fulltext searches and everything, any advice?
i've tried using ereg replace to strip the dashes back out and replace them with spaces, hoping that i'd still be able to match titles when the original one had a dash in it. like for example one title is "def-con zero" so i run it throug a prep script that strips whitespace and replaces it with a dash for the url so that becomes: def-con-zero for the url. then on the detail page before the query i use magic quotes gpc and addslashes to clean it up, and use ereg replace to take the dashes out and replace with a space so it becomes: def con zero for some reason the match against returns an empty result every time. i tried using the LIKE %variable% but if the variable in the database has a dash somewhere in the text, since i strip them all out and replace with spaces, MySQL won't match them up. if it makes any difference ive tried writing the query two different ways to no avail, one using sprintf and placing %s in the AGAINST, and one using just a straightforward query using the $colname_albumTITLE in the AGAINST.
i would but the idea is to make the urls friendlier to search engines. if you have underscores in the title like albums/def_con_zero it takes def_con_zero as one word, to my knowledge at least. so i'd like to use dashes if i can in the urls and then somehow clean it up so that i can pull from mysql based on that.
Always use dashes rather than underscores in my experience. The names in the database need to be free from dashes to start with and then you use $var= str_replace(" ", "-", $var); PHP: to add the dashes and the opposite to remove them.
Well, that is the issue- they're not free from dashes as they are proper names of artists, right? When I run into this problem, I just bite the bullet and use underscores for the dashes and dashes for the spaces. That way, most names (without dashes) are rendered as intended. I'm of the opinion now that a keyworded filename doesn't make that big of a difference when compared to other factors. Also, you can regularly see keywords highlighted in the results pages that are not separated properly.
That's fair enough and I also tend to agree. I guess I'm split between making the urls more friendly to search engines (as opposed to have them turning their noses up at url parameters), and also friendlier and more memorable to my readers. albums/def-con-zero is certainly easier to remember than albums/32. I think I'm going to do a little more probing of mysql to see if theres SOME way I can get them to match with a query otherwise I'll just leave it as is now. Thanks for your input and I'll definitely experiment with the methods you guys have suggested so far