fighnight Posted January 13, 2008 Share Posted January 13, 2008 Ok I am I creating a mysql query with the "like" addition and need help with blocking some features Example is use /changeroster.php?sort=s it shows everything including Shiny's,Shadow's how can I block that $cgstarer= mysql_query("SELECT * FROM username WHERE username like '$sort%' and owner='$u_info[id]' ORDER BY username ASC LIMIT $limitvalue, $limit"); /changeroster.php?sort=% it shows all the users how can I block or change that Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/ Share on other sites More sharing options...
Ken2k7 Posted January 13, 2008 Share Posted January 13, 2008 I don't understand what you mean by "block." Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437606 Share on other sites More sharing options...
fighnight Posted January 13, 2008 Author Share Posted January 13, 2008 Like changing it from % to some other letter Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437608 Share on other sites More sharing options...
Ken2k7 Posted January 13, 2008 Share Posted January 13, 2008 What are you trying to do? /changeroster.php?sort=s So what should that return? All names that start with the letter s? Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437612 Share on other sites More sharing options...
fighnight Posted January 13, 2008 Author Share Posted January 13, 2008 What are you trying to do? /changeroster.php?sort=s So what should that return? All names that start with the letter s? It supposed to return everything except shinyies and shadow Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437736 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 <?php $replace_to = $null; $sort = str_replace('%', $replace_to, $_GET['sort']); ?> Then just use $sort Change $replace_to as you please. Was only there to show you that you can change it. lol Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437738 Share on other sites More sharing options...
fighnight Posted January 13, 2008 Author Share Posted January 13, 2008 <?php $replace_to = $null; $sort = str_replace('%', $replace_to, $_GET['sort']); ?> Then just use $sort Change $replace_to as you please. Was only there to show you that you can change it. lol Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437740 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 <?php $replace_to = $null; $sort = str_replace('%', $replace_to, $_GET['sort']); ?> Then just use $sort Change $replace_to as you please. Was only there to show you that you can change it. lol Thank you! No problem. If your problem is now solved, please click the "Solved" button. Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437741 Share on other sites More sharing options...
fighnight Posted January 13, 2008 Author Share Posted January 13, 2008 Still need to find out the other question. Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437742 Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 % is a wildcard, if you don't want to use it then don't. Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437747 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 /changeroster.php?sort=s it shows everything including Shiny's,Shadow's how can I block that Of course it is. You're specifying to find *a string* + s. Its only logical that it will be returning Shiny's and Shadow's. Maybe you should tell us what your script is for exactly, so we can determine a better query. Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437795 Share on other sites More sharing options...
Hypnos Posted January 13, 2008 Share Posted January 13, 2008 I can only guess that the poster is trying to do one of two things... 1. Trying to block ambiguous searches that basicly show every result. 2. Trying to make a search for "s" match only " s ". I'm strongly guessing it's the first case. If it is, you should set a minimum amount of characters required for your search. Like 3. Quote Link to comment https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437800 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.