Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 3 123 LastLast
Results 1 to 10 of 29
  1. #1

    Post PHP/SQL tutorial

    For this you will need:
    PHP 5.1+
    mySQL
    A server, Or localhost.
    Ok, lets get started. (spoilers are just acting as tabs.)
    First, lets get the sql connection up and running:

    connect.php file:

    Now, we will do a basic database create.
    Code:

    this is how to insert:
    Code:

    How to create a table:
    Code:

    How to delete:
    Code:

    How to read:
    Code:

    Last edited by badboyxlr; 21-03-2011 at 09:12 PM.

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    This isn't a tutorial, it doesn't explain the code. It's more of a collection of code snippets, just like your other 'tutorial'.

  3. #3

    Default

    how about you read whats called a "comment" or the // bits in the code.. ide say that explains my code tyvvm.

  4. #4
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by badboyxlr View Post
    how about you read whats called a "comment" or the // bits in the code.. ide say that explains my code tyvvm.
    Ok, I'll read the comment in the first code snippet. What? It just says 'code for connected'? I'm reading this tutorial because I'm a beginner to PHP, how am I supposed to know what those functions do and why you're checking if $con is true?

    Second snippet. Oh look, only one comment and all it tells me is that we've just made connect.php. It doesn't tell me what the include() function does, or any of the other code there.

    Third snippet. Only one comment in there, but it is a tiny, tiny bit helpful. Has the same problem as the first two.

    Fourth snippet. Ok, you've explained a tiny, tiny, tiny bit of the SQL, but it isn't helpful. Has the same problem as the others.

    Fifth snippet. Same problems.

    Sixth snippet. Same problems.

    tyvvm gg

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    This isn't a tutorial. This is posting code snippets as Trinity said. You're not explaining the WHERE syntax, or anything to do with anything. You're just posting code snippets to do certain things.

    And usually it's the same file over and over.. this shouldn't be labeled as a tutorial, as it's not. A bad one at that.

  6. #6
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Also, when you make a connection file, you usually dont need to tell the script that includes the connect file to use that mysql connection again, it knows!

    When using " . $blah . ", you dont need to close it if you're not doing anything more to be outputting into the query, so its either "Hello {$name}" or "Hello " . $name; or "Hello " . $name . "";

    The way you have coded is in my opinion, bad practice, learn to code badly, expect to keep coding badly.

    For example, Im self taught in PHP, HTML, CSS, therefore my coding may not be as good, nor my knowledge be as good as someone whos been educated in it...

    Use the connect files to define everything to do with the connection...

    Lew.
    Im not here to be loved, I love to be hated :-}


  7. #7

    Default

    i am also self taught, and the way you have put that i dont know what your getting at, i have put it like this so that each item of the script is apart, so they dont have to have 1 huge script were if they want to insert they get a load of errors.

    ---------- Post added 22-03-2011 at 08:56 PM ----------

    yes i agree, but i put tutorial. Shame i cant edit it.. and do you always be so rude on posts, i am providing people with free snippets to copy and past, and all you do is criticize it?
    Last edited by badboyxlr; 22-03-2011 at 08:57 PM.

  8. #8
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by badboyxlr View Post
    i am also self taught, and the way you have put that i dont know what your getting at, i have put it like this so that each item of the script is apart, so they dont have to have 1 huge script were if they want to insert they get a load of errors.

    ---------- Post added 22-03-2011 at 08:56 PM ----------

    yes i agree, but i put tutorial. Shame i cant edit it.. and do you always be so rude on posts, i am providing people with free snippets to copy and past, and all you do is criticize it?
    I'm pretty sure we're all self taught here, it's no reason for us to use bad practices.

    You're the only person that's been rude in this thread, we're just being honest so that people reading the thread understand that this isn't the way to do things, then they'll learn from other places and become PHP gods.
    You can learn a lot on this forum too if you lose the attitude.

  9. #9
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    One of my favorite PHP lines is
    PHP Code:
    <?=(($this=$that) ? 'This &amp; That' 'That &amp; This')?>
    You'll soon learn how to deal with "errors" in php

    Lew.
    Im not here to be loved, I love to be hated :-}


  10. #10

    Default

    or, you could do it the easy way.. if (!$string){code for error}

Page 1 of 3 123 LastLast

Posting Permissions

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