robgolding63 Posted April 24, 2007 Share Posted April 24, 2007 Hi, I have just setup a new site for articles relating to windows server, networking and the like. I am writing the articles myself, and at present the HTML source for them is stored in a MySQL database. It's nice and fast, but a bit hard to edit the articles once they are published. Is there a better way to do this? Also, my article edit form uses a textarea box for the HTML source, but if I have an article with a textarea in it, the browser ends the <textarea> that is used for editing the article, and prints out the rest of the article onto the page! If I could fix this problem, then I could live with keeping the articles in the database, but I just cant think of a solution! I thought about maybe storing just HTML files, and having a PHP file check them every so often, loading the contents into the database for fast access from the site, but also easy editing by myself, just using Dreamweaver. Hope someone can help! Rob Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 Have a site template, then include the content of the requested page. To edit; edit the includes files directly, if ya need some help e-mail me: shaun dot rigby at gmail dot com Quote Link to comment Share on other sites More sharing options...
Barand Posted April 24, 2007 Share Posted April 24, 2007 Convert your articles using htmlentities() <?php $txt = htmlentities("<textarea name='mycode'>blah</textarea>"); echo $txt; ?> Quote Link to comment Share on other sites More sharing options...
robgolding63 Posted April 24, 2007 Author Share Posted April 24, 2007 The problem with the htmlentities this is, I actually need it to still be in parseable HTML format, so that when it is fetched from the database, it is parsed properly. In reply to shaun, that sounds like a good plan! If I store the details about the article in the database, with the name of a HTML file that contains the content, I can just include that - hows that for a plan? Thanks guys, Rob Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 YES! then call for the page by a reference eg http://www.mysite.com/index.php?padeid=7375 then lookup that code in your db, get the referenced page, then include it, else either load an error page or load a default page such as your index page Quote Link to comment Share on other sites More sharing options...
robgolding63 Posted April 24, 2007 Author Share Posted April 24, 2007 OK it's all working already! I just copied all the sources from the DB into HTML files, and changed the articles class to include it instead. Also, I made my own getcontents() funtion, so that if the file doesn't exist for some reason, I dont get an ugly error! If you're interested I can post the code. The site is www.maxms.net - I only have 7 articles so far, so it was quick to transfer all the sources over. This'll make it much easier to edit them. Thanks! Rob Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 make sure to use addslashes() to your GET's as you are opening yourself up to attacks Quote Link to comment Share on other sites More sharing options...
robgolding63 Posted April 26, 2007 Author Share Posted April 26, 2007 I have all this working nicely, and I should be all sured-up against SQL-injection, but I wanted to ask about performance. When I print a list of articles, in a category for example, the PHP has to get the first 100 characters from each HTML file. Is this a big perfomance hit? I can post the code if it would help, but basically it gets the contents of each file, then uses substr() to get the first 100 characters. It has to do this for every article being printed out in the list, so it's like a summary for each one. Thanks, Rob Quote Link to comment Share on other sites More sharing options...
robgolding63 Posted April 26, 2007 Author Share Posted April 26, 2007 Any ideas? I thought about having a PHP file load the first 100 characters into a summary field in the DB, and checking the file every so often to see if it has changed. The only problem I would have is how to get a PHP file to run on a schedule, on a windows server (can't do a CRON job). Thanks, Rob 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.