Jump to content

Absolute vs Relative Paths


watagal

Recommended Posts

GreetingsI have "index.php" in my root dir and a subdir called "Php_code" for the remaining php files. When I use include(), I get 'file not found' when I call a php file from a <a href> on my page.I would like to just use absolute paths, but not sure on the best way to impliment this. Any ideas?TIA, Gal

Link to comment
Share on other sites

It's probably better to use relative paths, then it doesn't matter which server you're on. If you're getting a warning that it can't find the file, make sure that the spelling and capitalization is the same. If you're getting a 404 not found error, that's not the include file it's the script itself. But if your server is a Linux server then it will be case-sensitive.

Link to comment
Share on other sites

Thanks, right now i'm on a local version of windows' xampp.Everything works fine when the "/index.php" calls (include) the '/Php_code/querySQL.php' which calls a sibling file (connect.php) and then calls another sibling file (drawHTML.php). Now when I select a link from the drawn page which references the 'querySQL.php' file (with GET arguments) - I get the error ('connect.php' not found).Syntactically, it works one way - but not the second way.Clear as mud? It there a good article or tutorial on this subject? Does PHP understand "./" or "../" or "../../" relative pathing?Gal

Link to comment
Share on other sites

Here's the errors:Warning: include(connect) [function.include]: failed to open stream: No such file or directory in D:\xampp\htdocs\mysite.com\php_code\querySQL.php on line 16Warning: include() [function.include]: Failed opening 'connect' for inclusion (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\mysite.com\php_code\querySQL.php on line 16Gal

Link to comment
Share on other sites

It looks like you're trying to include "connect" instead of "connect.php".
That's it. It turns out the extension for my current PHP extension was defined in another include file (vars.inc) which was called only in "index.php" and I was short circuiting that.Thanks, sorry for the fuss. Sometimes it just takes a new set of eyes.Gal
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...