This is the exact part of the code that doesn't work
if(isset($_GET['Champion'])){
$championget = trim(urldecode($_GET['Champion']));
echo $championget;
$championexists = $conn->prepare("SELECT * FROM champions where Champion = ?");
$championexists->bind_param('s', $championget);
$championexists->execute();
$championexistsresult = $championexists->get_result();
if(mysqli_num_rows($championexistsresult)==0){
echo 'Champion doesn\'t exist';
exit;
}elseif(mysqli_num_rows($championexistsresult)>=1)
{
//Continue here
include('php/champion.php');
exit;
}
}
Works fine with regular names like http://localhost/leaguenotes/Cassiopeia but i have names that have ' in them that is why i encoded them so they look like this http://localhost/leaguenotes/Cho%27Gath but this redirects me to folder index
Here is also htaccess that might be at fault
ErrorDocument 404 /
ErrorDocument 403 /
Options ALL -Indexes
RewriteEngine On
RewriteRule ^([0-9/.]+)$ index.php?Patch_No=$1 [NC,L]
RewriteRule ^([0-9/.]+)&([0-9a-zA-Z_-]+)$ index.php?Patch_No=$1&tab=$2 [NC,L]
RewriteRule ^patches php/patches.php [NC,L]
RewriteRule ^([0-9a-zA-Z_-]+)$ index.php?Champion=$1 [NC,L]
It just seems like because of %27 my code doesn't interpert this as a variable
Don't use them. Stick purely to A-Za-z0-9 and _ . (There are some other characters you can use, but they are reserved and have special meaning).
Anything URL encoded (e.g. %27
) get decoded before the URI is sent through the rewrite rules, that means you can't try to match against %27
, but to what that decodes to.
So instead of the regex:
[0-9a-zA-Z_-]
you need to include the apostrophe
['0-9a-zA-Z_-]