[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 05-15-2006, 02:26 PM   #1 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


php error

It says unexpected t_variable or something - line 6 (highlighted)

PHP Code:
$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 SecondVersion; 05-15-2006 at 03:18 PM. Reason: [COLOR] doesn't work in [PHP] ;)
PoorDoggie is offline  
Old 05-15-2006, 02:35 PM   #2 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
PHP Code:
[COLOR=Red]$sub = eregi_replace($domain, "" $sub);[/COLOR]
that is your problem

presumably you meant to have:-

PHP Code:
$sub = eregi_replace($domain, "" $sub);
but this is still wrong it should be (notice the comma after the quotes) :-

PHP Code:
$sub = eregi_replace($domain, "", $sub);
Peter is offline  
Old 05-15-2006, 02:44 PM   #3 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
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. ^^
Dan is offline  
Old 05-15-2006, 03:30 PM   #4 (permalink)
 
BillyConnite's Avatar
 
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,107
47.00 NP$ (Donate)

BillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant futureBillyConnite has a brilliant future

Wildlife Parkinson's Disease Parkinson's Disease
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.
__________________
<?php if(1===1){ $computer="fine."; }else{ $computer="broken."; } echo "Your computer is ".$computer; ?>
BillyConnite is offline  
Old 05-15-2006, 11:17 PM   #5 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
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.
Xyzer is offline  
Old 05-16-2006, 10:21 AM   #6 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


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

[QUOTE=BillyConniteSo line 6 would be: $sub = str_replace($domain,"",$sub);
[/QUOTE]

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
PoorDoggie is offline  
Old 05-16-2006, 10:25 AM   #7 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
http://us3.php.net/manual/en/function.str-ireplace.php

Not case sensitive str_ireplace.

webmonkey: scroll down first?
Dan is offline  
Old 05-16-2006, 10:32 AM   #8 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
Good idea Dan, But i like to know that i know.
Xyzer is offline  
Closed Thread


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

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:56 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85