Jump to content

Recommended Posts

Here are header.php it is included in the index file. 

and header_image.php it is the file you guys have been helping me snazzle together!

 

Sorry, at this point I feel like i'm kinda being a hassle...

 

[attachment deleted by admin]

<?php

$domain = $_SERVER['SERVER_NAME'];
echo $domain;

?>

 

Run that code in the page on its own and tell me the result please.

 

pmcsravenstone.com

 

 

 

You are sure that wasn't www.pmcsravenstone.com as SERVER_NAME should include the www. also are you including the header_image.php file before the header.php file?

Scrap that then...

 


<?php

$domain = $_SERVER['SERVER_NAME'];

echo 'Domain: ' . $domain . '<br><br>';

$imgUrl = "http://www.pmcsravenstone.com/media/";
switch ($domain)
{
case "webdesign.pmcsravenstone.com":
  $imgUrl .= "web.png";
  break;
case "dental.pmcsravenstone.com":
  $imgUrl .= "dental.png";
  break;
case "family.pmcsravenstone.com":
  $imgUrl .= "family.png";
  break;
case "fun.pmcsravenstone.com":
  $imgUrl .= "fun.png";
  break;
default:
  $imgUrl .= "bridge.jpg";
  break;
}

echo 'Url: ' . $imgUrl . '<br>';

?>

 

Change header_image.php to that and we can find the problem from there...

Ok, so here is the correct code Andy so gratefully fixed up!

<?php

$domain = $_SERVER['SERVER_NAME'];

$parts = explode('.', $domain);

if ($parts[0] == "www"){

$parts = array_slice($parts, 1);

$url   = implode('.', $parts);

}else{

$url = $domain;

}



$imgUrl = "http://www.pmcsravenstone.com/media/";
switch ($url)
{
case "webdesign.pmcsravenstone.com":
  $imgUrl .= "web.png";
  break;
case "dental.pmcsravenstone.com":
  $imgUrl .= "dental.png";
  break;
case "family.pmcsravenstone.com":
  $imgUrl .= "family.png";
  break;
case "fun.pmcsravenstone.com":
  $imgUrl .= "fun.png";
  break;
default:
  $imgUrl .= "bridge.jpg";
  break;
}


?>

 

 

Ok, so here is the correct code Andy so gratefully fixed up!

<?php

$domain = $_SERVER['SERVER_NAME'];

$parts = explode('.', $domain);  /* splits the string into an array seperated
by the dots ie $parts[0] => "www", $parts[1] => "webdesign", etc...*/

if ($parts[0] == "www"){ // check if the first value of parts is "www"

$parts = array_slice($parts, 1); // if it is remove the first value

$url   = implode('.', $parts); 

/* 'implode' the array values back into a string and add
the dots between each value back and set the string to the $url variable..*/

}else{

   $url = $domain;  // else $domain is ok to use, set it to $url var

}



$imgUrl = "http://www.pmcsravenstone.com/media/";
switch ($url) // change the switch case to $url instead of $domain.
{
// the rest all works the same.

case "webdesign.pmcsravenstone.com":
  $imgUrl .= "web.png";
  break;
case "dental.pmcsravenstone.com":
  $imgUrl .= "dental.png";
  break;
case "family.pmcsravenstone.com":
  $imgUrl .= "family.png";
  break;
case "fun.pmcsravenstone.com":
  $imgUrl .= "fun.png";
  break;
default:
  $imgUrl .= "bridge.jpg";
  break;
}


?>

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.