Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Code not displaying content
Old 11-16-2008, 09:40 PM Code not displaying content
Experienced Talker

Posts: 38
Trades: 0
I have recently put all my sites on symlinks and currently they all share the same template which means they all have the same content,title and descriptions. I am trying to make it so I can edit each sites info via a text files.

What I have so far is this

On the top of my index page I have this

PHP Code:
<?php $titles = @file("titles.txt");  

$count_titles=count($titles);  

$domain_name $_SERVER['HTTP_HOST']; 
if (
strpos($domain_name"www.") === 0
    
$domain_name substr($domain_name4); 

$domain_title=""$domain_description=""$domain_content=""

for (
$i=0;$i<$count_titles;$i++){ 
    if (
strpos($titles[$i],"$domain_name"."_title=") === 0){ 
        
$domain_title_parse=explode("=",$titles[$i], 2); 
        
$domain_title=trim($domain_title_parse[1]);         
    } 

    if (
strpos($titles[$i],"$domain_name"."_description=") === 0){ 
        
$domain_description_parse=explode("=",$titles[$i], 2); 
        
$domain_description=trim($domain_description_parse[1]);         
    }     
    if (
strpos($titles[$i],"$domain_name"."_content=") === 0){ 
        
$domain_content_parse=explode("=",$titles[$i], 2); 
        
$domain_content=trim($domain_content_parse[1]);         
    } 


?>
Where is want the content I have this

PHP Code:
<?php echo $domain_content?> 
<?php echo $domain_title?> 
<?php echo $domain_description?>
In the titles.txt I have this

PHP Code:
sample.com_title=       Test Title 
sample
.com_description=     Test Description 
sample
.com_content=     Test Content 
I am not getting any errors but its not displaying anything either so I am lost as to what is wrong.
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
 
Register now for full access!
Old 11-17-2008, 04:29 AM Re: Code not displaying content
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
<?php $titles = @file("titles.txt");
The @ symbol will suppress any warnings generated by the file function. Other than that you can try outputing someone of your variables at different stages of your code. Print out the entire titles array, count_titles, and anything else that is relivant.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-17-2008, 04:43 AM Re: Code not displaying content
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Well it works for me provided you change it to $domain_name=sample.com.

Clearly $_SERVER['HTTP_HOST']; has to match with the domain in the text file

Last edited by maxxximus; 11-17-2008 at 04:47 AM..
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 11-17-2008, 09:15 AM Re: Code not displaying content
Experienced Talker

Posts: 38
Trades: 0
Quote:
Originally Posted by maxxximus View Post
Well it works for me provided you change it to $domain_name=sample.com.

Clearly $_SERVER['HTTP_HOST']; has to match with the domain in the text file
Could you explain how you wrote it in the text file as I am not getting output also the text file is like this its not just one domain its several

PHP Code:

sample
.com_title=       Test Title 
sample
.com_description=     Test Description 
sample
.com_content=     Test Content

------------------------------------------------------

sample1.com_title=       Test Title 
sample1
.com_description=     Test Description 
sample1
.com_content=     Test Content

----------------------------------------------------------------------------

sample2.com_title=       Test Title 
sample2
.com_description=     Test Description 
sample2
.com_content=     Test Content 
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
Old 11-17-2008, 10:09 AM Re: Code not displaying content
Experienced Talker

Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
Trades: 0
Quote:
Originally Posted by ChillyWilly View Post
Could you explain how you wrote it in the text file as I am not getting output also the text file is like this its not just one domain its several
PHP Code:

dyna
.pumppumedia.com_title=       Test Title
dyna
.pumppumedia.com_description=     Test Description
dyna
.pumppumedia.com_content=     Test Content

------------------------------------------------------

sample1.com_title=       Test Title
sample1
.com_description=     Test Description
sample1
.com_content=     Test Content

----------------------------------------------------------------------------

sample2.com_title=       Test Title
sample2
.com_description=     Test Description
sample2
.com_content=     Test Content 
You'd need to change sample.com,sample1.com or sample2.com to match your.domain.name to see the title assigned to it,...
you're assigning $domain_name to $_HTTP['server_host']; which you're referring to in the code... so the above modified content worked for my test platform without modifying one line in your code, just the first batch in the txt file. So if you'd want the text associated to sample1.com sample2.com etc, you'd need to have access to them, and upload the code TO sample1.com, sample2.com and so on, OR they need to point to the same place...

hope this wasn't too complicated of an answer, but cheers, just change the domain to match your's and you'll see content :>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by jabis; 11-17-2008 at 10:11 AM.. Reason: got confused and rewrote a small part, lol
jabis is offline
Reply With Quote
View Public Profile Visit jabis's homepage!
 
Old 11-17-2008, 10:19 AM Re: Code not displaying content
Experienced Talker

Posts: 38
Trades: 0
OK thanks I feel real dumb now I was putting the text file in the common folder instead of the domain root. Since there is no symlink to the text file it wasnt reading it in the common I dropped in the root to test and works fine. Will make symlinks for it also so its all in one folder.


Thank you everyone


Actually I got away with adding the actual file path in the header "/home/common/titles.txt" and it works so saved me some work
__________________

Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE
::
Please login or register to view this content. Registration is FREE

Last edited by ChillyWilly; 11-17-2008 at 10:25 AM..
ChillyWilly is offline
Reply With Quote
View Public Profile Visit ChillyWilly's homepage!
 
Reply     « Reply to Code not displaying content
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30659 seconds with 12 queries