Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Is this possible? txt to html through php
Old 03-15-2008, 01:49 PM Is this possible? txt to html through php
Novice Talker

Posts: 5
Trades: 0
The free hosting service I use doesn't allow MySQL, and I want to make a blog page that would at least know how to separate the data to multiple pages. I got an idea to store all the posts (with html tags) in a txt file and have a script that reads the required portion of it (based on the page number) and putting it into the html file that the user loads (the posts are counted using a special tag that the script will search for).
I'm a complete php noob though and my attempts so far have been unsuccessful. What I'd like to know is: is it possible, is php the right language for it, and do you have some advice on how to get it done, or at least know a good tutorial or php functions/syntax archive.
I searched the web for php information and composed a short script, but it doesn't do anything and I don't know if the problem is syntax related or lack of knowledge about the various nuances of the functions I used.
Here it is in case you want to take a look:
Code:
<?php 
            $file = fopen("blogdatabase.txt", "r");
            &page=0;
            $counter=$page*10;
            while(!feof($file) && $counter!=$page*10+1){
                $temp=fgets($file);
                if ($temp=="(post)")
                    $counter++;
            }
            fclose($file);
            echo $temp;
            ?>
Thanks in advance.
BlackRiven is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-15-2008, 08:02 PM Re: Is this possible? txt to html through php
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Maybe one reason your script example is not working is because you have an amperstand starting a var name. Change to the following:

$page = 0;
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 03-15-2008, 08:22 PM Re: Is this possible? txt to html through php
Defies a Status

Posts: 1,606
Trades: 0
PHP will process a text file as html. If it contains <tags> they will be processed and the output rendered.

Follow Mg's suggestion and see if it works.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 03-15-2008, 09:41 PM Re: Is this possible? txt to html through php
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
If your host provide PHP5, maybe the sqlite support is enabled.
You could use it, as it's a real database engine.

http://www.php.net/manual/en/ref.sqlite.php
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-15-2008, 10:40 PM Re: Is this possible? txt to html through php
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
If you have a blog then you could/should just use rss and parse the RSS with PHP for your page.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to Is this possible? txt to html through php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15335 seconds with 12 queries