Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Php error

SpaceshipSpaceship
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
It says unexpected t_variable or something - line 6 (highlighted)

PHP:
$sub = $_SERVER['HTTP_HOST']; // get host
$domain = "6yd.net";
$sub = eregi_replace($domain, "" $sub); //<-- line 6?!
$sub = eregi_replace("www\.", "", $sub);
$sub = strtolower($sub);
if(!empty($sub)){
  include("shorturl/do_short_url.php");
}

anyone know what's wrong?

Thanks
Tom
 
Last edited by a moderator:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
[COLOR=Red]$sub = eregi_replace($domain, "" $sub);[/COLOR]

that is your problem

presumably you meant to have:-

PHP:
$sub = eregi_replace($domain, "" $sub);

but this is still wrong it should be (notice the comma after the quotes) :-

PHP:
$sub = eregi_replace($domain, "", $sub);
 
0
Close
He meant to have the [COLOR] stuff there so you could find it easier.. but that doesn't work in
PHP:
.

All you need is a comma. ^^
 
0
Close
As Peter showed, the leaving out of the comma was the problem.

But just a note, you should always try to optimize what you can in PHP to make things nice and quick, every little bit counts.

So for the first line I'd suggest using str_replace rather than eregi_replace, as its quicker to process.

So line 6 would be: $sub = str_replace($domain,"",$sub);

All the best!
Rhett.
 
0
Close
I hate it when i come to programming threads, i work it out and find the problem, scroll down the thread and its finished lol.
 
0
Close
Thanks a lot everyone, I can never figure it out, post it here, and then feel so stupid because it is sooooo obvious. Thanks for all your help though

BillyConniteSo line 6 would be: $sub = str_replace($domain said:
is str_replace() case dependant though? eregi_replace isn't which is why I use it. I suppose in this case I could use "strtolower" or something.

Thanks
Tom
 
0
Close
0
Close
Good idea Dan, But i like to know that i know.
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back