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

Php error

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
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
•••
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
•••
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
•••
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
•••
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
•••
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
•••
0
•••
Good idea Dan, But i like to know that i know.
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back