+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Database, MySQLl, PHP, site template, blog = Oh GOD!

  1. #1
    luca85 is offline x10Hosting Member luca85 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    24

    Question Database, MySQLl, PHP, site template, blog = Oh GOD!

    Well, I've built a website similar to TMZ.com but instead of the news posts there are personal posts like in a blog. Then it hit me that I was going to need a database (new to this) for ease of adding posts, keeping track of them and search option. So I did a little bit of research and ended up installing MySQL, Apache and PHP on my computer. And then everything went blank.

    My question is, considering that I already have the website built, how do I add content to my website as posts using PHP, MySQL?

    I've created some tables in command prompt trying to understand MySQL, that's as far as I got.

    Trying to learn...

  2. #2
    bidzey75's Avatar
    bidzey75 is offline x10Hosting Member bidzey75 is an unknown quantity at this point
    Join Date
    Apr 2011
    Posts
    51

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    your asking somebody to write you a book, that's a pretty big question...
    start here

    you'll close in on section 8

    it's old 2004, but he explains well, and for now that's important, you can always google other sites if you want more recent.
    Last edited by bidzey75; 05-12-2011 at 09:17 PM.

  3. #3
    luca85 is offline x10Hosting Member luca85 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    24

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    That's what I need, information. Well, I learned how to build websites pretty fast using easier ways than writing code. Hopefully I'll soon find the easier way here as well, like finding on the web the exact PHP scripts that I need for what I'm dealing with.

    Thanks for the link.

  4. #4
    bidzey75's Avatar
    bidzey75 is offline x10Hosting Member bidzey75 is an unknown quantity at this point
    Join Date
    Apr 2011
    Posts
    51

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    well all the luck to you.

    If you rely on software to code for you that's ok, but if you never learn what it does and why it's doing it, you'll always be confined to the software your using and trapped in it's box. Iknow there's alot of software out there that will design sites for you without you knowing HTML, but I don't kow of too many that will do that for PHP + MySql. Then again I never really looked for some, so maybe they do exist. Once you get by the logic layer, it get alot easier, and you'll be glad you've decided to go through the learning curve. PHP is not complicated and is a really cool coding language.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    Quote Originally Posted by bidzey75 View Post
    The database sections are dangerously out of date. The old mysql and sqlite extensions shouldn't be used as (among other reasons) they don't support prepared statements, which are extremely important in preventing SQL injection. Those extensions have been supplanted with (most recently) PDO and SQLite3 (which also supports UTF-8 and UTF-16). More troubling, the document doesn't even mention injection. It uses sqlite_escape_string in one script fragment, but never mentions why.

    See also "PHP tutorial that is security-, accuracy- and maintainability-conscious?"
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    fretwizz is offline x10Hosting Member fretwizz is an unknown quantity at this point
    Join Date
    Jun 2008
    Posts
    57

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    Quote Originally Posted by luca85 View Post
    That's what I need, information. Well, I learned how to build websites pretty fast using easier ways than writing code. Hopefully I'll soon find the easier way here as well, like finding on the web the exact PHP scripts that I need for what I'm dealing with.

    Thanks for the link.
    If you find the "the easier way here as well" please let me know;)

  7. #7
    luca85 is offline x10Hosting Member luca85 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    24

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    Hey, well I've been quite busy since I've started this topic and got some basic understanding of CSS, JavaScript, PHP etc to the point where I can write (well, copy paste alter) code, built pages, links, forms etc and having them seen on the web. But, as I'm still a noob in the matter and I would like to shorten the time that it would take to find certain information, maybe someone can help me with a piece of code.

    1) While getting intimate, lol, with PHP I found a/some command/code that automatically inserts the contents of a file into an HTML page. Now I was thinking maybe I can use this to update sections of my website just by changing the contents of that file without the use of a database. Does anyone know what's the function that I'm talking about? And if you know, is that a good way to update a section (like blog posts) of a website?

    2) Does anyone know the code for arranging text files added to a page by most recent to oldest like in a blog or forum? Hopefully it will be a simple piece of code although I doubt it as I've been looking for something like that for a while now.

    Thanks.

  8. #8
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    1. There's readfile to output a file without any additional processing (except for any stream wrappers or filters you explicitly set up). For PHP scripts, there's include/include_once/require/require_once to process the files as PHP. For other scripted pages, there's virtual, which performs an Apache sub-request to fetch the page (note: the result isn't processed as PHP); this function is only available if PHP runs as an Apache module and not a CGI process.

      As for including frequently changing content from another file, it's not much different than editing the file doing the inclusion. If you're using FTP to publish content, then the author needs the same level of access either way. If you're using a web-based editor to edit the file directly, having a separate file can both simplify the editor (as it doesn't need to handle extraneous, write-only portions of the page) and increase security (you don't need to worry about bugs allowing someone to change the write-only sections). On the down side, you need to handle simultaneous edits and all the other stuff that a DBMS does for you.
    2. If you're using the filesystem to store things, you're responsible for fetching and organizing the data. A database, in contrast, can handle much of that for you.

      If you're storing the content in separate files and want to show it in order of file creation or modification,
      1. use glob or opendir+readdir to get the list of filenames, then
      2. stat to get the time of interest.
      3. Store the filename and time in an array of arrays or objects (it doesn't matter which),
      4. define a function to compare elements by the time and
      5. use usort to sort the array.
      6. Loop over the now sorted array, outputting the file content.
      It might look something like:
      PHP Code:
      <?php

      function make_fileinfo($name) {
          
      $file = new StdClass;
          
      $file->name $name;
          
      $info stat($name);
          
      $file->time $info['mtime'];
      }
      function 
      cmp_mtime($a$b) {
          
      # newer times are sorted lower.
          
      return $b->time $a->time;
      }

      $files array_map('make_fileinfo'glob('news/*.txt'));
      usort($files'cmp_mtime');
      # limit output to 5 items
      $maxPosts 5;
      ?><ul class="posts"><?php
      foreach (array_slice($files0$maxPosts) as $idx => $file) {
          
      ?><li><?php
          readfile
      ($file->name);
          
      ?></li><?php
      }
      ?></ul><?php
      If you want to use some other criteria for sorting the files, you'll have to take care of that as well, by (e.g.) storing the order in another file.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  9. #9
    bachvtuan88 is offline x10Hosting Member bachvtuan88 is an unknown quantity at this point
    Join Date
    Oct 2010
    Posts
    3

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    Simple, you can uses some free cms such as wordpress, joomla or tomatocms to build a website.
    Otherwise, if you want make a webiste for yourselft, it is depend in yourself.

  10. #10
    luca85 is offline x10Hosting Member luca85 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    24

    Re: Database, MySQLl, PHP, site template, blog = Oh GOD!

    @misson: thanks a lot for the info
    @bachvtuan88: I don't want to rely on a cms

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Database (Wordpress blog) not working
    By secretss in forum Free Hosting
    Replies: 3
    Last Post: 08-13-2010, 02:49 PM
  2. TV Show database and blog
    By saddx in forum Review My Site
    Replies: 5
    Last Post: 04-24-2010, 03:08 AM
  3. My Blog is down for last 4 days. Database Error
    By s603zone in forum Free Hosting
    Replies: 2
    Last Post: 02-02-2010, 05:49 AM
  4. How can i get the DATABASE of my blog!
    By shyam123 in forum Free Hosting
    Replies: 3
    Last Post: 12-27-2007, 07:38 PM
  5. working on a new blog template
    By ZeptOr in forum Graphics & Webdesign
    Replies: 8
    Last Post: 04-08-2007, 11:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers