SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Member SiteViper's Avatar
    Join Date
    Feb 2001
    Location
    USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Building a Database-Driven Web Site Using PHP and MySQL

    I am more than half the way through the 10 segment course and I must say I am impressed.

    I have only found 1 problem so far. (Damn good since I find fault with everything.)
    That problem would be that in the begining Kevin did not identify the need to use the address http://localhost/file.php to open the files as they are created on a home or local system. He did identify all of the necessary parameters for a hosted site, but then, I am not doing that just yet.

    I also have a question for the forum:
    I am at the point in where I have added a delete function to my db. This function takes out the entire entry (in this case: id, joketext, jokedate). Cool!
    But, why is it that when you delete an entry, the order becomes mixed up.
    Example: I have 22 jokes in my db. I deleted entry number 11, 13, and 19. The display is still in the same order. Now if I add 2 jokes (using the link on the page) they are displayed where the first 2 were deleted.
    I thought perhaps this was because of the order of the array, but I can close my browser clear the cache, and reopen the file.php and it is still in the remixed order.

    WHY?

    Thanks again Kevin...GREAT JOB!

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this is down to some inconsistencies with the auto-update feature of mySQL. You can get round this by ordering the jokes by another known field (such as the date the joke was added or the joke title if you want it to be alphabetical) - I think this is covered later in the tutorial.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A principle of relational database theory is that "rows" (tuples) within a table are not ordered and there is no implicit relationship between rows. The only principle that must be observed is that each row must be identifiable by at least one unique field - a PRIMARY KEY.

    This is good news becuase, in general, the RDMS provides us with a layer of abstraction. We create tables, insert into, update and delete records in our tables using SQL without any regard for what is really going on "under the hood" in terms of how and where this data is being physically stored on the hard disk. Each RDMS will have its own strategies fow how it goes about arranging and storing our data.

    If we stick to the principals of relational database design we can leave the details to the RDMS and those black magic wizards known as DBAs.

    As Skunk says, you can use ORDER BY in your SQL to sort your result set. Look up ORDER BY in the mySQL manual ( www.mysql.com ) if you are not familiar with it.

  4. #4
    SitePoint Enthusiast Synozeer's Avatar
    Join Date
    Dec 2000
    Location
    Florida
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm interested in taking a look at this tutorial. Where would one find it?

    Thanks.

  5. #5
    SitePoint Addict klisis's Avatar
    Join Date
    Sep 2000
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know it's way off topic but I couldn't help.

    .... Synozeer
    What is that avator picture about?! Is it real?!

    Sorry for going a bit off topic.,

  6. #6
    SitePoint Enthusiast Synozeer's Avatar
    Join Date
    Dec 2000
    Location
    Florida
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *grin*

    It's not me, that's for sure Just one of the funny pictures I have on my humor site that I thought was cute. I'm pretty sure it's a real picture, but I have no idea who the kid is. I simply call him "Toilet Boy".

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Building a Database-Driven Web Site Using PHP and MySQL
    http://www.webmasterbase.com/article.php/228

    I also like the tutorials at www.devshed.com

    There was a thread recently with heaps of links to online php/mysql resources.

  8. #8
    SitePoint Member SiteViper's Avatar
    Join Date
    Feb 2001
    Location
    USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THROUGH Part 5.
    ERRORs found:
    Kevin missed a few letters in the $dbcnx var. and typed it $cnx .
    Also, there is a discontinuity on how he types the Field name Email.
    The variety he uses: eMail, EMail, and Email.
    This is obviously important to right since MySQL is case sensitive in this matter.
    I also found some mistyped html...opening tags where closers should be.

    Also, in Part 5, he addresses different means of relating authors to the jokes and early on he says all that is needed is to add some authors to the db. He doesn't say to do it, or warn how, but in the very next segment, he seems to want you to display for yourself how the authors look. He even gives the MySQL command.
    I decided it best to put the info in my pocket for later use and not try to add the authors since I figgured the relationships might not be complete. Was a good idea!

    More later (unless someone says stop).

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Keep going, SiteViper! I'm writing these all down!

    There are actually a couple of bugs in Part 6 that I am aware of as well, and the Windows installation section (which currently uses Microsoft PWS as the Web server) needs to be redone to use a more friendly server (I tend to recommend Sambar).

    The article will be getting an update to correct all these little niggles as soon as I have time, which unfortunately at this point is looking to be sometime in April.

    I'll also be providing the MySQL code to generate the final database structure as required by Chapter 6.
    Last edited by Kevin Yank; Feb 26, 2001 at 21:13.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  10. #10
    SitePoint Member SiteViper's Avatar
    Join Date
    Feb 2001
    Location
    USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by kyank
    Keep going, SiteViper! I'm writing these all down!
    OK Kevin, YOU ASKED FOR IT!
    Code:
    Part 6:
    A. No "Description" support was added to the category controls in newcat.php or editcat.php
    B. There is a typo …edit joke.php mirror their…must make provide the same…   Just don't make much sense to me.
    
    Part 7:
    A. We start the lesson by making changes to joke.php.  Huh, we never made anything called joke.php, and there is no such file in the code.zip files. So, I assumed we were going to work with the initial display since everything that follows doesn't fit with the jokelist.php code.
    B. The code starts to get confusing because it doesn't match what we did initialy.  Ex. The Display Text area used a fairly different format that left me to my own devices. (not a bad way to force me to think, but I worked it out)
    C. The eregi code demo is a waste of space since the only difference is the "i" added to the ereg code just above it.
    D. Regular Expression Syntax: PHP //matches "What is PHP?"  Should also match "PHP rules!" ?
    E. Question: \$\$\$   Do you have to do this 3 times for "Show me the $$$!"  Wouldn't defining $ with one \$ for all $ located within the text suffice?
    F. $newstring = ereg_replace(<regexp>, <replacewith>…  Sometimes you show the space after the comma, and others you don't.  Does it matter?  I notice this happens to often for my logical brain to find a pattern, so I assume its just the "lose" factor of PHP.
    G. The replacement of  \n\n with <P> in our filter systems seems to open a paragraph tag for which I can find no close.  We may need an explanation here.
    H. Putting It All Together: (This may be due to the lack of joke.php, or I may have missed something, but our original public display file had a delete option that is not considered or shown now. (I guess I am learning successfully because I dealt with it and still have the link in my working page ;) )
    I. $joke = mysql_fetch_array($joke);   This section of code returns the following in my browser:  Warning Supplied argument is not a valid MySQL result resource in /filepath/joke.php 
    I even tried using just the code from the lesson with the necessary path and access changes, but the same error returned.  Is this a valid statement?
    J. [PAGEBREAK] causes all kinds of weird anomalies. When following the Next Page link, the result is an array of Previous Page links where all of the jokes would be.  The only text shown is that of the PAGEBREAK Joke.
    K. Typo:  The link for Previous Page as show is -Next Page-. ;)
    L. Again, I may have made a mistake in file selection since I didn't find joke.php, but the resulting array of jokes was such a mess that I would have closed my browser without reading a single joke if I were a visitor. 
    This prompted me to test the skills I have learned by following your lesson this far. (2/3 through Part 7)
    I rearranged quite a bit of the code and formatted the list into a TABLE. J
    I also added filters for underline ability and followed the more common bbs style of markups using [/b]  rather than using something like [eb].
    Here is a text file of the file I have completed to date.

    Given that I successfully reformatted the code, I would have to say that Kevin's work still get a high grade from me!

    To be continued…

  11. #11
    SitePoint Member SiteViper's Avatar
    Join Date
    Feb 2001
    Location
    USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way,
    How did you folks add those custom avatars to your profile?
    ...the help link on this forum is darn usless. :/

  12. #12
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've been busy by the looks of it SiteViper!

    Re Avitars:
    http://www.sitepointforums.com/showt...threadid=16076

  13. #13
    SitePoint Member SiteViper's Avatar
    Join Date
    Feb 2001
    Location
    USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...continued.

    Part 7 complete.

    M. Finaly confounding the confusion. Automatic Content Submission points out that we discarded the "Add joke function" in our public access document. We did? I didn't see that anywhere.

    N. The remaining confusion is solidified by indication that all of the work with the filters was apparently supposed to be added to the "Admin" documents and not the "Public" document.
    As I indicated in A. & B. of my Part 7 review, there was no clear indication as to which document to edit, and the code in the "Admin" documents did not come close to what was being shown at the begining of Part 7.

    O. Typo: Two paragraphs prior to Wrap-Up ...but it is inappropWith new jokes... It appears that the paragraph is repeated in part. (at least in the html document that I downloaded)

    I won't be heading into Part 8 just yet as I plan to go back and fix up a few things in that I feel are missing in the Admin and Public Document.

    I will post more .txt files as I finish them.
    And Yes freakysid...I have been busy!!!

  14. #14
    SitePoint Member
    Join Date
    Feb 2001
    Location
    El Paso, TX
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi...
    Just a comment, I recently worked my way through the tutorial, and am in the process of building a couple "practical" applications using my new found knowledge. The application I'm currently building is a "bills" database, I have a couple friends working in Saudi Arabia, and while they're there I am receiving their mail, and notifying them of their bills and such, so I decided to build a database for their bills, and the account information that goes with them to simplify the process, and I figured it was a good way to get a little practical experience applying what I'd learned. Well in the process I wanted to be able to include links to websites in the account info where they were available.

    Then I noticed some accounts also gave e-mail addresses, and thought why not a mail to link, well Kevin's code works just fine for those too, with one small change, add an @ to the search string, I also used eregi_replace instead of ereg_replace, so the code in Kevin's tutorial looks like:
    Code:
     
        // Hyperlinks
          $joketext = ereg_replace(  "\[L]([-_./a-zA-Z0-9!&%#?,'=:~]+)\[EL]",
          "<A HREF=\"\\1\">\\1</A>", $joketext);
          $joketext = ereg_replace(  "\[L=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
          "([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[EL]",
          "<A HREF=\"\\1\">\\2</A>", $joketext);
    mine looks like:
    Code:
     
        $ano = eregi_replace("\[L]([-_./a-zA-Z0-9!&%@#?,'=:~]+)\[EL]",
        "<A HREF=\"\\1\">\\1</A>", $ano);
        $ano = eregi_replace( "\[L=([-_./a-zA-Z0-9!&%@#?,'=:~]+)]".
        "([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[EL]",
        "<A HREF=\"\\1\">\\2</A>", $ano);
    Thought it might be something helpful.
    Also, Kevin's tutorial was my first experience with php, mysql, so I'm kind of wondering if what I did could cause any potential problems? It's working for me at the moment, but I could just be getting lucky with my server/browser combination.

    Halsey

  15. #15
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin Yank:

    I'll also be providing the MySQL code to generate the final database structure as required by Chapter 6.

    Thankyou so much...I guess you read the thread that i started!

    Thanks again, I really want to do this so that I can try out the scripts easily and have a look at your coding style. It differs largely from mine. Yours is much neater and I'm trying to convert.

    -Peter

  16. #16
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Comments Received!

    Just wanted to let everyone who contributed to this thread know that the 2nd Edition is nearing completion, and I believe I've addressed all the concerns that were raised in this thread.

    Thanks again for your feedback, everyone!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  17. #17
    SitePoint Member
    Join Date
    Jul 2001
    Location
    Bournemouth UK
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comments Received!

    Originally posted by kyank
    Just wanted to let everyone who contributed to this thread know that the 2nd Edition is nearing completion, and I believe I've addressed all the concerns that were raised in this thread.

    Thanks again for your feedback, everyone!
    Great tutorial kevin!

    and well done to siteviper for the input!

    i have been following this thread and wondered when can we expect the updates to go live kevin?

    cheers

  18. #18
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A Question for Kevin, or anyone that has read through his article!

    Hi Everyone,

    I have been trying to figure out how to add the capability for uploading a file to the structure laid out in Kevin's article. To keep with the examples Kevin gives, let's say that I wanted to add the option of uploading large joke files instead of having the administrator type them all out (this would be an option only available to the administrator of the DBMS, not the general public, for security reasons). What I would want to do is to allow them to browse their harddrive and choose the file, then upload it to the remote server. In addition, it would store the actual file name of the joke file (which would ALWAYS be in PDF format...no other type of file would be uploaded) in a new column in the database called jokename. This would allow for the filename to be appended to a set URL where the joke files would be kept (e.g. -
    "http://www.pit-viper.snake.net/jokes/" . "jokes1.pdf" (<- from the original filename which is stored in a PHP variable from what I can gather).
    This new URL, dynamically formed by a PHP script would be then stored in the new "jokename" column in the MySQL database...I am unsure of whether this column would only have to exist in the jokes table or if it would have to be in other tables as well though.
    The URL that is now stored in the MySQL database would be searchable to both the administrator of the DBMS and the general audience of the site, and this would allow them to simply click the link to load up the joke file they had searched for.
    I hope that my question made sense, and that either Kevin (if you are still checking this thread) or someone that has worked through the article that has a bit more experience with these matters might be able to help me out.

    Cheers,

    XGuy.

    (P.S. - Anyone that helps me with this will become my new hero )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •