Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

71 users online



can't think of a way..

can't think of a way..

Currently viewing this thread: 1 (0 members and 1 guests)


trunks

trunks

asdf
Status: Offline!

can't think of a way..

Okay. so when I'm writing scripts that are using flat files, like a vote script for example, I'm coming across a problem.

I want it to be included in my index, or people wants to do so. But when you include the file, you can't make it run like if it was directly run from it's absolute path... which means if my script and flatfile was in directory /temp and my index is in /, my script won't work anymore because the script is looking for the flatfile in / instead of /temp...

anyone have a way to get across this problem? to get it to work both when it's directly ran through url and when included from another directory...

:/

midsummerstorm

midsummerstorm

28, Male & single, what else do you need to know?
Status: Offline!

You can make it work with an argument that specifies where the flatfile has to be saved (and retrieved later on). Something like:

PHP:


<?php
include("/voting/vote.php");
$flat_file_path "/voting/flatfile.txt";
do_vote($flat_file_path);
?>

Of course, I'm assuming you're using a function to access the script from other pages. Eventually everything can be turned into a function, but you could also use a class, or just rely on the variable $flat_file_path to be set before you include the script.

Since if you don't include an absolute path, the file will be created on the same folder than the script is parsed, I can't see any other workaround for this issue.

___________________

-~-~-~oO··Oo~-~-~-~-
I wish I was a messenger and all the news was good
I wish I was the full moon shining off your camaros hood
...

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0159 seconds.