ivatanako Posted September 11, 2007 Share Posted September 11, 2007 I am new into PHP programming and Im making a simple php site for my school project. Im having issues with the fopen function in PHP. I wanted to make a FOPEN php file, something like this http://domain.com/viewarticle.php?name=sample.txt Is this possible without mySQL? so that whenever I'll request for a page, it'll just fetch the textfile on the webserver. The url would be something like this. http://domain.com/viewarticle.php?name=sample.txt http://domain.com/viewarticle.php?name=sample2.txt ??? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 What is the problem? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 11, 2007 Share Posted September 11, 2007 Why would you need mySQL for this? You would just treat it as a normal text file. <?php $file = $_GET['name']; $handle = fopen($file, "r"); ?> Quote Link to comment Share on other sites More sharing options...
ivatanako Posted September 11, 2007 Author Share Posted September 11, 2007 Ok, I do apologize.. <?php $file = $_GET['name']; $handle = fopen($file, "r"); ?> I have this save as viewarticle.php. Then i'm trying to fetch sample.txt, how would i do this? I tried this one http://domain.com/viewarticle.php?name=sample.txt But it didn't fetch the text file. What am I missing? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 11, 2007 Share Posted September 11, 2007 Give this a try. <?php $file = $_GET['name']; $lines = file($file); foreach ($lines as $line) { echo $line.'<br>'; } ?> Quote Link to comment Share on other sites More sharing options...
ivatanako Posted September 11, 2007 Author Share Posted September 11, 2007 That's all I need. Thank you.. 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.