Jump to content

[SOLVED] Retreive domain name


bschultz

Recommended Posts

My company has four domain names.  Each of the four websites uses the some of the same info gathered from a database...and I would like to replace the "we" with the company name.

 

Here's the example of what might be in the database:

 

We are going to have a float in the Memorial Day parade

 

With this:

 

The XYZ Company will have a float in the Memorial Day parade

 

Obviously, I can't put php code into the database to determine which domain they are viewing the article from...so how can I enter the info into the database (and more importantly, retrieve it), so that the company name would replace "We"?  Mind you, not all entries into the database will have a company name...so I can't just replace every "WE" with the "company name"

 

Thanks.

 

Brian

Link to comment
Share on other sites

personally I would define the company name in each project..

 

define('COMP_NAME', 'XYZ Company');

 

so you will have one in each site.  Afte that its a case of deciding which ones you wish to replace using something like:

 

<?php
...
$str = preg_replace('/we/i',COMP_NAME,$str);
...
?>

 

Your problem is decerning which occurences are to be replaced...

 

 

Link to comment
Share on other sites

right...but I don't want to replace all "We"'s with Company Name.

 

I'd like to have this in the database:

 

<?php
if (strpos(getenv('SERVER_name'), 'domanin1.com')!==false) {
echo "Company 1";
} elseif (strpos(getenv('SERVER_name'), 'domanin2.com)!==false) {
echo "Company 2";
} elseif (strpos(getenv('SERVER_name'), 'domain3.com')!==false) {
echo "Company 3";
};
?> 
will have a float in the Memorial Day Parade.

 

but I can't insert php code into the database...but I can't think of any other way to only replace the company name when I want to...and not every time.

 

 

Link to comment
Share on other sites

Alright...I'm dumb.  I was so set on replacing WE (since that's how I currently enter the info into the db) that it never dawned on my to enter COMPANYNAMEHERE (or some other completely random thing) into the db where the company name was supposed to go.

 

Upon looking at preg_replace and how it needs to be written, how can I turn this:

 

 
echo "<span class='itemdetails2'><br /><br />".stripslashes($row[story])."</span><br /><br /></td></tr>"; 

 

into the string to be replaced?

Link to comment
Share on other sites

if you are going to insert a specific term that is going to be replaced the we can just use the str_replace function - more effiecient as it doesn't have to do all the funky regex work.

 

It will still need you to define the company name for each site and that would best be done as I suggested earlier - by defining a constant for each site (in this example I'll stick to the COMP_NAME).

<?php

echo "<span class='itemdetails2'><br /><br />".str_replace('COMPANYNAMEHERE',COMP_NAME,stripslashes($row[story]))."</span><br /><br /></td></tr>";

?>

 

That should accomplish all you need...

Link to comment
Share on other sites

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.