I am creating a blogging system and need some help. A entry with it's tile will be stored in a file. 1 entry per file. PHP will need to create the file and write to it but i have one problem:

How will PHP generate the filename?
How will it tell the title and entry apart as well as the date?

Thanx
Adam

    if you need a unique filename try using the md5 function or uniqid (or both: md5(uniqid("")); )

    The Second one...I have no idea what your talking about.

      Are you SURE you want to create a blogger using files?? Sounds to me like you need MySQL, not a file system. A database is much better suited to this task.

        i completey agree with Stinger51, you don't need to re-invent the wheel, your already existing wheel is mySQL (and it's a free wheel). if you absolutely MUST use flat files then i suggest you use UNIX timestamps along with the entry title as your filename (little chance of 2 people submiting an entry with the same title at exactly the same second.)

        $filename = time() . '_' . $title;

          I would use MySQL but it is too difficult.

            Originally posted by adamb10
            I would use MySQL but it is too difficult.

            You will soon find that creating an efficient flatfile database is even more difficult.

              Yeah I know but I dunno what to do about it. I tried reading tuts and they didn't help me.

                I would suggest Julie Meloni's "PHP Fast & Easy Web Development." The 2nd half of the book deals entirely with MySQL. If you have any previous DB technology, it's pretty easy to learn MySQL dev. Your investment in it will pay handsome dividends later on. Trust me on that one. 🆒

                I tried to do what you are doing, using flat files instead of a relational database, for a long time on a project. And it ended up being a nightmare. And I also almost ended up creating my own DBMS! This is NOT something you want to spend your valuable time on, believe me! Far better to use what is out there, as others here have also told you. Otherwise, you may as well try to build the Panama Canal using a bucket and shovel.

                Again, take the time to learn to do it right, using the right tools from the git go. You'll be very glad you did.

                  I am kinda poor right now and am saving for a mac so I can't really buy a book. Do you know any tuts though on mySQL?

                    I just gave you the name of a good "tut."

                    But I think you are just stringing us along here. My advice to you is to quit flubbing yur dong on a magazine like Playboy and spend your hard earned money on a good programming magazine.

                    And you'll find more answers to your questions too. 🆒

                      Ooooh, Ooooh, Ooooh.... My turn...

                      Try poking your head into the FREE online PHP and MySQL manuals.

                      Then put together some code, and come back here to seek some help in getting the code to work properly.

                      Ooooh, here's another FREE resource. Try your local public library. Hopefully, yours is as high quality as the one in the city where I live. If it doesn't have too many books on PHP and MySQL, you should be able to make requests. Either way, you wouldn't need to dig into books too much if you took the time to dig into the manual. Good luck with it.

                      The bottom line is this: Flatfile systems can be useful depending on the application, but in this case, this application... flatfiles are definitely NOT the way to go. Since you don't know what you are doing with flatfiles and MySQL, you'd better serve yourself by taking the time to learn MySQL from the start.

                        Write a Reply...