bsv77 Posted August 13, 2011 Share Posted August 13, 2011 I have a re-write rule that takes the URL such as: /products/?bookname=late-rain and displays it like: /products/late-rain and the my script uses the bookname value to search the database. I am running into an issue in that if the value is say "Late Rain" with spaces or "Late-Rain" with dashes, the script will not use that as it should. What is the best way to query something like WHERE bookname = "late-rain"? It may instead be the rewrite as it adds a trailing / when it does not work. If there are no spaces or anything, it works just fine. Thanks for the advise in advance. Link to comment https://forums.phpfreaks.com/topic/244707-url-variable/ Share on other sites More sharing options...
AbraCadaver Posted August 13, 2011 Share Posted August 13, 2011 You need to do a echo $_GET['bookname']; and see what is there. Link to comment https://forums.phpfreaks.com/topic/244707-url-variable/#findComment-1256919 Share on other sites More sharing options...
bsv77 Posted August 14, 2011 Author Share Posted August 14, 2011 Yes, I know how to see the variable, the issue is that it does not work when there is a dash in the url like "book name" Link to comment https://forums.phpfreaks.com/topic/244707-url-variable/#findComment-1257152 Share on other sites More sharing options...
voip03 Posted August 14, 2011 Share Posted August 14, 2011 In my knowledge you cannot use dash for variables. Please check with ' php rules' Link to comment https://forums.phpfreaks.com/topic/244707-url-variable/#findComment-1257161 Share on other sites More sharing options...
skwap Posted August 14, 2011 Share Posted August 14, 2011 You are not provided your code. Use this example - <?php $book_name = trim(strtolower($_GET['bookname'])); $book_name = str_replace(" ","-",$book_name); ?> Link to comment https://forums.phpfreaks.com/topic/244707-url-variable/#findComment-1257239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.