Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/
Share on other sites

<?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. :)

Link to comment
https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437741
Share on other sites

/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.

Link to comment
https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437795
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/85745-php-mysql-query-help/#findComment-437800
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.