Forum Moderators: open

Message Too Old, No Replies

the title tag with -

the title tag with -

         

aff_dan

12:20 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



I have this code:

<?php if ($REQUEST_METHOD=='POST') {

$titlu = urlencode( $_POST['Keywords'] );

} elseif ($QUERY_STRING) {

$titlu = urlencode( $_GET['Keywords'] );

} else {

echo "<b>Missing XML Query &#151; Use form (POST) or querystring (GET)</b>"; exit;

}?>

<title><?php echo $titlu ;?></title>

The title is with "-" between keywords when a search is performed.

For exemple, the title tag will be: Make-Advertising
How to remove -?

Danni

mcibor

6:46 pm on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php if ($REQUEST_METHOD=='POST') {
$titlu = urlencode( $_POST['Keywords'] );
} elseif ($QUERY_STRING) {
$titlu = urlencode( $_GET['Keywords'] );
} else {
echo "<b>Missing XML Query &#151; Use form (POST) or querystring (GET)</b>"; exit;
}
$titlu = str_replace("-", " ", $titlu);
?>

<title><?php echo $titlu ;?></title>


Sorry for not doing that in javascript, but I don't know is as well as I do php.

Best wishes
Michal Cibor

I recommend [pl.php.net...]

aff_dan

6:40 am on Apr 20, 2005 (gmt 0)

10+ Year Member



Thank you very much! It is working.

But sometimes I have search.php?Keywords=web+site

You see "+" between keywords, How can I add this in php code, I tryed
$title = str_replace("+", "-", " ", $titlu);
but I get error

regards,
dani

mcibor

8:06 pm on Apr 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$what_to_replace = array("+", "-");
$replace_with = array(" ", " ");//I'm not sure if just $replace_with = " "; wouldn't be enough

$titlu = str_replace($what_to_replace, $replace_with, $titlu);

I really recommend seeing the page: [pl.php.net...]

Best regards
Michal Cibor

Chrome

8:54 pm on Apr 20, 2005 (gmt 0)



Hi

The spaces in a string can be replaced with +'s using:

$titlu = urlencode($titlu);

If you want to replace with - with + too try:

$titlu = urlencode(str_replace('-', '+', $titlu));

Chrome

aff_dan

8:01 am on Apr 21, 2005 (gmt 0)

10+ Year Member



Hi,

I used this and it is working!

<HTML><HEAD>
<?php if ($REQUEST_METHOD=='POST') {
$titlu = urlencode( $_POST['Keywords'] );
} elseif ($QUERY_STRING) {
$titlu = urlencode( $_GET['Keywords'] );
} else {
echo "<b>Missing XML Query &#151; Use form (POST) or querystring (GET)</b>"; exit;
}
$titlu = str_replace("-", " ", $titlu);
$titlu = str_replace("+", " ", $titlu);
?>
<TITLE><?php echo $titlu ;?></TITLE>

But I have a problem. When I make rewrite rules using:

Options +FollowSymLinks
RewriteEngine On
ReWriteRule ^search/([A-Z0-9a-z_]*) /search.php?Keywords=$1 [L]

I will transform to:

site.com/search/anykeywordhere.html

BUT BUT, the search results from site.com/search.php?Keywords=anykeywordhere is VERY very different from site.com/search/anykeywordhere.html

WHY?

Regards,
Dan

mcibor

12:56 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



site.com/search.php?Keywords=anykeywordhere ==> the site is search.php

is VERY very different from site.com/search/anykeywordhere.html ==> the site is anykeywordhere.html in folder search.

They are two different sites. I don't know what you want to do with it.
Tell us what is it that you want, and I'll try to help
Michal CIbor