I have been trying to fix this issue for 2 days now with no avail.
basically, I am trying $_GET
results from mysql based on whatever is in the URL passed on from the previous page.
the url is like this: http://mydomain.com/manufacturer/abc
to achieve this URL, i am using .htaccess
which works fine.
but if the url has an empty space
or a -
or any other special characters, my php file won't GET the results from the mysql database.
so this won't work:
http://mydomain.com/manufacturer/a-b-c
or this won't work:
http://mydomain.com/manufacturer/a b c
nor does this:
http://mydomain.com/manufacturer/a+bc
etc etc....
I am using smarty which so far was a very straight forward process but now that it has come to this, it has proven to be a bit difficult.
my php file looks like this:
if (isset($_GET['man'])) {
$man = $_GET['man'];
if( ! $stmt = $db_conx->prepare("SELECT id, man, product_name FROM `$TabelName` WHERE `man` = ?") ) {
die( $db_conx->error );
}
$stmt->bind_param('s', $man);
if ( ! $stmt->execute() ) {
die( $stmt->error );
}
$stmt->bind_result($id, $man, $product_name);
$stmt->store_result();
while($stmt->fetch()) {
$value[] = array('id'=>$id, 'man'=>$man, 'product_name'=>$product_name);
}
}
// Assign this array to smarty...
$smarty->assign('man', $value);
// Assign this array to smarty...
$smarty->assign('$man', $value);
}
and this is my htaccess file:
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^manufacturer/([a-zA-Z0-9]+)$ manufacturers.php?manu=$1
RewriteRule ^manufacturer/([a-zA-Z0-9]+)/$ manufacturers.php?manu=$1
I have tried urlencode
and urldecode
in every which way possible, and nothing seemed to work.
could someone please advise on this issue?
Thanks in advance