sintax63 Posted April 16, 2014 Share Posted April 16, 2014 (edited) I found the issue: $letters = ereg_replace("[^A-Za-z0-9 ]", "", $searched); Thanks everyone. Edited April 16, 2014 by sintax63 Quote Link to comment https://forums.phpfreaks.com/topic/287823-special-characters-in-search-string/ Share on other sites More sharing options...
mac_gyver Posted April 16, 2014 Share Posted April 16, 2014 where and how is the search term $q being input? have you echoed your $query to make sure it contains what you expect? Quote Link to comment https://forums.phpfreaks.com/topic/287823-special-characters-in-search-string/#findComment-1476395 Share on other sites More sharing options...
Solution sintax63 Posted April 16, 2014 Author Solution Share Posted April 16, 2014 Well the issue I'm having now is with the # symbol itself. It is getting tossed up into the address bar, but my code seems to be ignoring it when I echo it out on the page. Quote Link to comment https://forums.phpfreaks.com/topic/287823-special-characters-in-search-string/#findComment-1476406 Share on other sites More sharing options...
QuickOldCar Posted April 16, 2014 Share Posted April 16, 2014 (edited) wrong post I did somehow Edited April 16, 2014 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/287823-special-characters-in-search-string/#findComment-1476408 Share on other sites More sharing options...
QuickOldCar Posted April 16, 2014 Share Posted April 16, 2014 Hash marks and fragments get ignored through the address bar. Run this example on what you can do or not to see the fragment. <?php $url = filter_var("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); if (!empty($_SERVER["QUERY_STRING"])) { $query_string = filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_STRING); $url .= "?" . $query_string; } echo "<h4>what your script sees from address bar</h4>"; echo $url . "<br />"; //as can see here, nothing through $_server shows the fragment print_r($_SERVER); echo "<h4>client side using javascript</h4>"; echo "<script language='javascript'> document.write(window.location.hash); </script>"; echo "<h4>directly from server or in code</h4>"; $url = "http://site.com/page#fragment"; //example 1 echo parse_url($url, PHP_URL_FRAGMENT) . "<br />"; //example 2 echo end(explode("#", $url)) . "<br />"; //example 3 $arr = parse_url($url); //print_r($arr); echo $arr['fragment']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/287823-special-characters-in-search-string/#findComment-1476419 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.