Ed* Posted January 28, 2007 Share Posted January 28, 2007 I have a script which need to find the path domainroot/cat from bothdomainroot/year/month/day/blogpost &domainroot/pageIf I set the path to ./cat only /page will find the way - but not the other one.How do I solve this? ???(The script will load images from /cat)[code]<?php getImages('./headers', 'myShow');?><?php function getImages($path, $galleryName) { ....................[/code] Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/ Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 Your question is not at all clear enough. Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170873 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 The script is included in the <head> and will be run at all pages on the domain, for example domain.com/page domain.com/year/month/day/blogpost. I need the $path to work from both of these... Or a way to rewrite the code for it to work... :-[ Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170875 Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 You need to look into the $_SERVER['DOCUMENT_ROOT'] variable. Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170876 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 I tried this:[code]<?php getImages('$_SERVER['DOCUMENT_ROOT']/domains/[domain.com]/public_html/headers', 'myShow');?><?php function getImages($path, $galleryName) {[/code]Received this:Parse error: syntax error, unexpected T_STRING in /home/[user]/domains/[domain.com]/public_html/wp-content/themes/281/header.php on line 19 Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170881 Share on other sites More sharing options...
linuxdream Posted January 28, 2007 Share Posted January 28, 2007 This..<?php getImages('$_SERVER['DOCUMENT_ROOT']/domains/[domain.com]/public_html/headers', 'myShow');?>needs to look like this...<?php getImages($_SERVER['DOCUMENT_ROOT'] . "/domains/[domain.com]/public_html/headers", 'myShow');?> Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170886 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 Seems like I made a bad edit of the script. The line should be something like:<?php require $_SERVER['DOCUMENT_ROOT'] . "/mooshow/folderImages.php"; getImages($_SERVER['DOCUMENT_ROOT'] . "/headers", 'myShow');?>Guess something is wrong in the require-command... Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170902 Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 There is nothing wrong with php's require [b]function[/b]. What seems to be the problem now? Your last post isn't clear. Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170903 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 <?php require "./mooshow/folderImages.php"; getImages("./headers/", 'myShow');?>works for domain.com/cat1 but not domain.com/cat1/cat2<?php require $_SERVER['DOCUMENT_ROOT'] . "/mooshow/folderImages.php"; getImages($_SERVER['DOCUMENT_ROOT'] . "/headers/", 'myShow');?>works for neitherno errors, but errors are showing if altering the paths to something unexisting. Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-170911 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 No one knows? Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-171080 Share on other sites More sharing options...
Ed* Posted January 28, 2007 Author Share Posted January 28, 2007 Case closed -> echo( produced incorrect paths to the images in the end of the script, thus the images wasn't showing. 8)Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/36017-solved-path-from-rootabcd-to-rootx/#findComment-171155 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.