semanticdm Posted May 11, 2008 Share Posted May 11, 2008 Hi, I'm working in an environment where I don't have access to SQL, and have had to come up with some interesting methods to try and work around that. One method I think will work is to use a bunch of flat files, and have a config file to control which files are used. However, I've run into an issue - when I pull information out of the config file related to filenames of the other files, it doesn't work. The code in question: $myFile = "./frontpagearticles/testFile.txt"; $fh = fopen($myFile, 'r'); $theData = fgets($fh); echo file_get_contents( $theData); $theData = "./frontpagearticles/" . $theData; echo file_get_contents( $theData); echo file_get_contents("./frontpagearticles/allstar.txt"); testFile.txt is just a simple text file with the names of the files that should be used. ./frontpagearticles/ is the directory that all the articles live in. If I try Hard coding in the data $theData = "./frontpagearticles/allstar.txt" works. It's only when I try to pull in the information from the config file that the problem occurs. Any help or ideas of what might be going on would be greatly appreciated. Thanks! Tom Bowersox Quote Link to comment Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 try using trim(). not sure if this will help but it's worth a shot $myFile = "./frontpagearticles/testFile.txt"; $fh = fopen($myFile, 'r'); $theData = trim(fgets($fh)); echo file_get_contents($theData); $theData = "./frontpagearticles/" . $theData; echo file_get_contents($theData); echo file_get_contents("./frontpagearticles/allstar.txt"); Quote Link to comment Share on other sites More sharing options...
semanticdm Posted May 11, 2008 Author Share Posted May 11, 2008 That worked perfectly. Thanks! Tom Bowersox Quote Link to comment 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.