UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 29th June 2008, 05:44 PM   #1 (permalink)
urbanxtremes
Registered User
 
urbanxtremes's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 86
Geting rid of spaces in a url

Hello,

Does anyone know of a way that I can remove the spaces from a link and place an underscore; the link is calling the page "header" and "id" from the database.

<a href='news_content.php?id=$id=$hpagesheader' title='$hpagesheader'>

This is what I am getting in the url:
news_content.php?id=4=What%20not%20to%20do%20on%20 an%20internship

But I would like this:
news_content.php?id=4=What_not_to_do_on_an_interns hip

Any ideas?

Cheers
__________________
~~~~~~~~~~~~X~~~~~~~~~~~~

Who Cares?

~~~~~~~~~~~~X~~~~~~~~~~~~
urbanxtremes is offline   Reply With Quote
Old 29th June 2008, 07:00 PM   #2 (permalink)
percepts
Senile Member
 
percepts's Avatar
 
Join Date: Mar 2005
Posts: 984
look up str_replace in the PHP manual
__________________
An old dog learning new tricks
percepts is offline   Reply With Quote
Old 30th June 2008, 08:38 AM   #3 (permalink)
Simon
Dedicated to life!
 
Simon's Avatar
 
Join Date: Jul 2005
Location: 36°38'4.48"N - 4°42'18.52"W
Posts: 2,058
Send a message via MSN to Simon Send a message via Yahoo to Simon Send a message via Skype™ to Simon
Quote:
Originally Posted by urbanxtremes View Post
Code:
<a href='news_content.php?id=$id=$hpagesheader' title='$hpagesheader'>
I suspect what you really want is
Code:
<a href='news_content.php?id=4&header=Some_header_string' title='Some header string'>
Using = to seperate the id and the header are going to complicate things in your news_content.php script

As percepts said, you need str_replace
PHP Code:
echo "<a href='news_content.php?id=$id&header=".str_replace(' ''_'$hpagesheader)."' title='$hpagesheader'>"
__________________
Freelance PHP Programming
__________________

Last edited by Simon : 30th June 2008 at 08:40 AM.
Simon is offline   Reply With Quote
Old 30th June 2008, 09:09 AM   #4 (permalink)
TygerTyger
Lumberjack and OK
 
Join Date: Aug 2004
Posts: 823
Code:
echo "<a href='news_content.php?id=$id&amp;header=".str_replace(' ', '_', $hpagesheader)."' title='$hpagesheader'>";


Don't forget when you're getting something from the database you will need to change it back again, replacing underscores with spaces, notice the order in str_replace has been switched.

Code:
$hpageswhatever = mysql_real_escape_string(str_replace('_', ' ', $_POST['hpagesheader']));
TygerTyger is offline   Reply With Quote
Old 30th June 2008, 03:42 PM   #5 (permalink)
urbanxtremes
Registered User
 
urbanxtremes's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 86
It is a good thing we never meet up for a drink, as I would end up p**sed and shouting the usual geezers tout “I love you guys”

Thanks for your help.
urbanxtremes is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 03:33 AM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309