anthonyv Posted May 11, 2007 Share Posted May 11, 2007 Hey there, Wondering if anyone could assist me with something that is actually pretty simple for someone who knows their PHP. I don't know enough to be able to write from scratch (learning), whilst i can generally edit existing samples to fit my needs. Please see the attached file which is a description of my problem and my solution to it... i just require help with the correct syntax/writing the code. if u look at the attachment, the code hightlight in red is what i'm trying to achieve (just not written correctly for php to process). Thanks in advance. Anthony. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/ Share on other sites More sharing options...
anthonyv Posted May 11, 2007 Author Share Posted May 11, 2007 ok with the assistance of an old friend i got this far; <?PHP <!-- this will list the directory that you are actually in e.g. "member1" --> $Member = dirname ($_SERVER[php_SELF]); echo $member <!-- now you have that you can just include it in the path for the header to make the right path name --> $header="../headers/header_".$Member.".html"; ?> <? include("$header") ?> <? include("current.html") ?> however something seems wrong because the page just shows up blank? Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250586 Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 You have a syntax error. <?php // note this is only an html comment not a php comment // <!-- this will list the directory that you are actually in e.g. "member1" --> $Member = dirname($_SERVER['PHP_SELF']); // array index references should always be enclosed with single quotes. echo $member //<-- now you have that you can just include it in the path for the header to make the right path name --> $header="../headers/header_".$Member.".html"; ?> <?php include("$header") // should always use <?php ?> <?php include("current.html") ?> Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250592 Share on other sites More sharing options...
anthonyv Posted May 11, 2007 Author Share Posted May 11, 2007 Thank you. Appreciate the response, however, the page still shows up blank? oh, and the "echo $member" was just so i could see if it would return that on screen... but it doesn't. just a plain whitepage ??? Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250602 Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 try it with this echo $Member; Remember that php is Case Sensitive and I forgot to add the ; to the correction list. Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250605 Share on other sites More sharing options...
anthonyv Posted May 11, 2007 Author Share Posted May 11, 2007 ok i stripped out all the comments and this is what i've got: <?php $Member = dirname($_SERVER['PHP_SELF']); // array index references should always be enclosed with single quotes. $header="../headers/header_".$Member.".html"; echo $Member; ?> <?php include("$header") ?><?php include("current.html") ?> i get the current.html showing, but the header is not showing. i do, however, get "/members/member1" at the top of the page, where the header should be... i can't work out why the header isn't showing? Path is correct... Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250614 Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 Are you sure that file exists. Because what you are essneitally trying to include is this: ../headers/header_/members/member1.html That does not seem like a valid file to me, but it maybe. I would check that and verify you are looking in the right direction. It also might be wise to turn on error reporting. Those syntax errors should have been visiable but are not due to php.ini configuration settings. Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250617 Share on other sites More sharing options...
anthonyv Posted May 11, 2007 Author Share Posted May 11, 2007 ../headers/header_/members/member1.html thats not what i wish to include. ../headers/header_member1.html is what i wish to include... really appreciate your help! Current code: <?php $Member = dirname($_SERVER['PHP_SELF']); $header="../headers/header_".$Member.".html"; ?> <?php include("$header") ?> <?php include("current.html") ?> Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250621 Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 <?php list(,$Member) = split("/", dirname($_SERVER['PHP_SELF']); $header="../headers/header_".$Member.".html"; ?> <?php include("$header") ?> <?php include("current.html") ?> The dirname is the full path to the php_self. In order to get away from that using the split function www.php.net/split and list www.php.net/list you can have $Member only contain the last part of the dir given that the DIR only has 2 parts to it. IE: members and members1 Note the code above is untested and may need tweeking. Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-250636 Share on other sites More sharing options...
anthonyv Posted May 14, 2007 Author Share Posted May 14, 2007 i tried the code but no joy, still blank page. tried tweaking with it to no avail. Please assist :-\ Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-252682 Share on other sites More sharing options...
anthonyv Posted May 17, 2007 Author Share Posted May 17, 2007 Thanks for the support. Problem solved. Close/Delete topic as required. Anthony. Quote Link to comment https://forums.phpfreaks.com/topic/50939-solved-please-advisehelp-thanks/#findComment-255149 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.