Jump to content


Photo

Help With Includes On Testing Server

include filename relative abs

  • Please log in to reply
1 reply to this topic

#1 backsmith

backsmith

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 13 December 2012 - 04:03 PM

Hi

This is aquestion about absolute and realative addressing across a web host and a local testing server.

I have just upgraded to Dreamweaver CS6 and want to use the php testing server. Previously I was just uploading everything and testing on the remote host.
Problem is that I use lots of includes in my pages. Content is in a directory tree. This is an example.

Content/conditions/back_pain/muscles.php

which looks like THIS

<?php
include("/home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/externals/main.php" );?>

Thats the whole page.

I use the full path because I use the same main.php to set out the layout for all the pages and a relative link fell down and I dont want to use a differnt relative path in each php file..


Then in the included main.php I have this function.

function curPageName() {
return "content/".substr(substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1),0,-4).".htm";
}


Any in the middle of the page I put

I use <?php
include( '/home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/'.curPageName() );

?>
which drops in the text from "content/muscles.php"

All works fine on the remote web host.

BUT

These long file paths are no use on my testing server which is at c:xampp/htdocs/mysite

I think I need to use a variable set to the first part of the file path and for this to be different on the host and the testing server.

eg
/home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/
or
c:xampp/htdocs/mysite



At last the question.....

How is this best done?

Thanks

John

#2 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 13 December 2012 - 05:12 PM

$_SERVER['DOCUMENT_ROOT']
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com