value is Tourism & Hotels

url?catagory=Tourism%20&%20Hotels&maincateg=Tourism%20&%20Hotels

if i call that catagory to another page

$category = $_GET['catagory'];

and in second page i displayed that value

echo $category;

but this showing only Tourism and the remaining words r gone.i want to display Tourism & Hotels with special char

You should escape an & with & or you can try urlencode()

is it correct

echo encode($category);

i used this one but its not working

oh sry that is urlencode() only

Member Avatar for diafol

If you encode it, remember to encode your values before building the querystring. If you try to urlencode after building the complete querystring, you'll end up encoding the '&' querystring-pair separator and the '=' too.

If the category is "Tourism & Hotels"

then encode, e.g.

$raw = "Tourism & Hotels";
$enc = urlencode($raw);

$url = '?category=' . $enc . '&maincateg=' . $enc;

//then

<a href="<?php echo $url;?>"><?php echo $raw;?></a>

So, test something like this...

<?php
if($_GET)
{
    echo "<pre>";
    print_r($_GET); 
    echo "</pre>";
}

$raw = "Tourism & Hotels";
$enc = urlencode($raw);

$url = '?category=' . $enc . '&maincateg=' . $enc;
?>

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<a href="<?php echo $url;?>"><?php echo $raw;?></a>
</body>
</html>    

Not sure if that's what you want though.

Thanks its working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.