WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum

Go Back   WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum > >

Design, Development & Programming You guys may be the nerds of the industry, but without your incredible techniques, no one would be able to operate anything. Yes, root is god.


Welcome to the WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Closed Thread
 
Thread Tools Display Modes
Old 11-26-2007, 11:52 AM   #1
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
Question php for some special characters

hello guys

I'm coding a site that will use mod rewrite to send the users to the real php generated page ( say search.php?id=123456) but I'll use mod_rewrite to make the url look like /somecategory/123456-TheNameOfThatThing.html

now the database I'm using happens to have any kind of crap in TheNameOfThatThing part including " * ' ] etc

is there a php function that I can use o "make the string clean"?
remember I don't car if the string is fucked and some chars are removed (I actually want to remove them), I won't use it to run the query, I'll use just the number

any idea?
or the only way to go is the good old str_replace used for all those characters?
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Sponsored Ad
Old 11-26-2007, 12:01 PM   #2
Houdas
Senior Member
 
Houdas's Avatar
 
Join Date: Dec 2006
Posts: 751
iTrader: 7 / 89%
Houdas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond repute
Code:
function seo_url ($title){  
    $address = $title;  
    $address = strtr ($address, "ČĎĚŇŘŤŮݎčďěňřťů ", "AACCDEEEINOORSTUUUYZaaccdeeeinoorstuuuyz-");  
    $address = strtolower ($address);   
    $re = "/[^[:alpha:][:digit:]]/";  
    $replacement = "-";  
    $address = preg_replace ($re, $replacement, $address);  
    $address = trim ($address, "-");  
    $re = "/[-]+/";  
    $replacement = "-";  
    $address = preg_replace ($re, $replacement, $address);  
    return $address;  
}
hope it helps
Houdas is offline  
Old 11-26-2007, 01:11 PM   #3
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
thanks Houdas!

what does exactly the virst regex ( $re = "/[^[:alpha:][:digit:]]/" ) mean???
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Old 11-26-2007, 01:34 PM   #4
argh01
Little Member
 
argh01's Avatar
 
Join Date: Oct 2007
Posts: 551
iTrader: 8 / 100%
argh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond repute
he's demonstrating a preg_replace. A cursory reading looks like he's leaving in the numbers and the letters. I think you only want the numbers, so leave out the [:alpha:] one.

basically "change everything that's not a digit to ''. "
argh01 is offline  
Old 11-26-2007, 01:38 PM   #5
argh01
Little Member
 
argh01's Avatar
 
Join Date: Oct 2007
Posts: 551
iTrader: 8 / 100%
argh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond repute
Wait, now I'm confused. I reread his function and it's doing something weird with the hyphens.

I'm assuming you have
123456-someotherstuff
and you want
123456

this preg_replace will fix that.

$input = "123456-something";

print "$input\n";

print preg_replace( "|[^\d]|", '', $input )."\n";
argh01 is offline  
Old 11-26-2007, 01:48 PM   #6
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
no, as I said in the first post I have something like 123456-Wireless*Mouse'Cool] and I want to remove all that crap, I don't care what's the output string: I'll explode it and use just the starting 123456 in my script, it's exclusively for SEO purposes
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Old 11-26-2007, 02:04 PM   #7
Houdas
Senior Member
 
Houdas's Avatar
 
Join Date: Dec 2006
Posts: 751
iTrader: 7 / 89%
Houdas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond repute
Actually the code I posted should convert any given string to "seo url" (ie. only alphanumeric characters and dashes). It works okay for me, but in any case, this is only one way of many how to do it (if you have the data in SQL database, you can do it directly in database too).
Houdas is offline  
Old 11-26-2007, 02:06 PM   #8
argh01
Little Member
 
argh01's Avatar
 
Join Date: Oct 2007
Posts: 551
iTrader: 8 / 100%
argh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond reputeargh01 has a reputation beyond repute
aah. Sorry then One more reason I shouldn't post before I've had my coffee.
argh01 is offline  
Old 11-26-2007, 03:08 PM   #9
Houdas
Senior Member
 
Houdas's Avatar
 
Join Date: Dec 2006
Posts: 751
iTrader: 7 / 89%
Houdas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond repute
no problem screw coffee, beer ftw!!
Houdas is offline  
Old 11-26-2007, 05:00 PM   #10
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
I'll test the code tomorrow

moreover guys, which one to you think is better among

123456-cheap-car-parts.html
123456-Cheap-Car-Parts.html
123456-cheapcarparts.html
123456-CheapCarParts.html

others?
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Old 11-26-2007, 05:35 PM   #11
Houdas
Senior Member
 
Houdas's Avatar
 
Join Date: Dec 2006
Posts: 751
iTrader: 7 / 89%
Houdas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond reputeHoudas has a reputation beyond repute
123456-cheap-car-parts.html is the best one IMHO. And is the .html on the end needed?
Houdas is offline  
Old 11-27-2007, 04:09 PM   #12
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
no, I just thought maybe .html is loved more?
it's just for optimization

do you think 123456-cheap-car-parts without html is better?
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Old 11-27-2007, 05:03 PM   #13
Stanley
Banned
 
Join Date: Jun 2006
Location: San Diego
Posts: 3,410
iTrader: 3 / 100%
Stanley Stanley Stanley Stanley Stanley Stanley Stanley Stanley Stanley Stanley Stanley
Quote:
Originally Posted by Icecube View Post
no, I just thought maybe .html is loved more?
it's just for optimization

do you think 123456-cheap-car-parts without html is better?
it makes no SEO difference
Stanley is offline  
Old 11-27-2007, 07:59 PM   #14
Icecube
Up 24h/day
 
Icecube's Avatar
 
Join Date: Mar 2007
Location: Europe
Posts: 1,172
iTrader: 11 / 100%
Icecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond reputeIcecube has a reputation beyond repute
thanks stanley

Houdas, the code is perfect, +rep
Quote:
Originally Posted by Houdas View Post
(if you have the data in SQL database, you can do it directly in database too).
what do you mean? how can I do it?
it might actually be better for the searches run against the db
__________________
Buy a cheap and reliable hosting plan using my affiliate link and get 3 months of payments refunded by me!
PM me for more info
Icecube is offline  
Closed Thread

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gift for WickedFire members - Holidays Sales Booster PHP Script nikolap Traffic & Content 0 12-29-2009 02:12 PM
GCN, Special characters, and approval time chrisr Traffic & Content 0 10-29-2008 01:09 AM
::Special Offer:: Get +220 .EDU .GOV, and .AC.UK Golden Backlinks Premium Package!! profithost Sell, Buy & Trade 0 05-25-2008 07:03 PM
Passing a subid to the merchant within a PHP redirect ImagesAndWords Affiliate Marketing 27 01-30-2008 09:32 AM
PHP type calculator???? jerxs Design, Development & Programming 6 01-12-2008 05:03 PM


All times are GMT -4. The time now is 01:58 AM.


Search Engine Optimisation provided by DragonByte SEO v1.2.9 (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
WickedFire.com Copyright 2014 - WickedFire is an international registered Trademark of Coastal Synergy LLC. You may not use any of our trademarks, copyrights, content, or images without a written approval by members of Coastal Synergy LLC. "Banners on this site that promote Wickedfire are satire unless clearly stamped as REAL".