RAWKHIGH Posted February 24, 2014 Share Posted February 24, 2014 (edited) This is my first time posting sorry if anything is wrong. attached are my files in question but i don't know what is wrong. I want to show info from a .txt file or something similar within the website I'm working on. In AS3 it was easy to read and use an xml file but within html/php i cant remember. i want to be able to have to have the people im making the site for to be able to just update the text file and it will update the certain part of the site with the new information. Currently for some reason its commenting out part of my php code that i believe should read and echo the lines of the text file. this is the php code: <div id="home"> <h3>Updates From the Staff</h3> <p> <?php $file = fopen("news.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { echo fgets($file). "<br>"; } fclose($file); ?> </p> </div><!-- End Nav Home --> this is what shows when i inspect element with chrome: <!--?php $file = fopen("news.txt", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached while(!feof($file)) { echo fgets($file). "<br--> its commenting out everything till the line brake and just showing "; } fclose($file); If someone could help me that would be amazing if not thats ok aswell. Edited February 24, 2014 by Zane Quote Link to comment Share on other sites More sharing options...
.josh Posted February 24, 2014 Share Posted February 24, 2014 looks to me like your server isn't setup to parse your file extension as a php file. When a file is requested, the server doesn't automatically go through the file looking for relevant script tags to parse. You must set it up to run it through things like php or perl or w/e based on the file extension. For example, if that code is in like somefile.html (I did not download your zip to look), the server's default settings are not setup to run an html file through the php interpreter. Quote Link to comment Share on other sites More sharing options...
RAWKHIGH Posted February 24, 2014 Author Share Posted February 24, 2014 its not currently on a server im using komodo edit and just previewing it in my browser. is that why not matter what i do i cant get it to show the text? Quote Link to comment Share on other sites More sharing options...
Solution davidannis Posted February 24, 2014 Solution Share Posted February 24, 2014 AFAIK you need to serve it through a server if you want to mix html and php and display it in a browser. There are local servers you can install on Windows, Linux, and Mac. Google WAMP, LAMP, or MAMP to get apache, MySql, and PHP all bundled together and easy to install on your OS. Quote Link to comment Share on other sites More sharing options...
.josh Posted February 24, 2014 Share Posted February 24, 2014 I haven't used komodo editor but doing a quick 1m glance at their site it looks like it's just an editor, doesn't have a server and php built into it to actually evaluate php code. As davidannis said, look into using something like WAMP or XAMPP. Komodo may even have a way in its settings to point to one of those for preview once they are installed (but I'll leave that research up to you) Quote Link to comment Share on other sites More sharing options...
RAWKHIGH Posted February 24, 2014 Author Share Posted February 24, 2014 thank you everyone for the help im going to dl xampp and get back to work. Thank you very much again to everyone for the help i feel kinda stupid for forgetting something so simple but now i can get back to work and show them an update. again because I'm new to the site and all is there anything i have to do to close this topic and say its finish? Quote Link to comment Share on other sites More sharing options...
.josh Posted February 24, 2014 Share Posted February 24, 2014 you can click the "Mark Solved" button on the bottom right of someone's post if you feel your question was resolved. 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.