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 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: PHP Help

  1. #11
    Join Date
    Nov 2006
    Location
    North Carolina, UA
    Posts
    128
    Tokens
    0

    Default

    If I make something I usually put

    session_start(); at the top of my page

    Cause I use sessions everywhere.
    ---------------
    I also use the account: Dentafrice
    ---------------

  2. #12
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    Just put the session_start function at the top of your page, you can then add datum you want to store to the superglobal array $_SESSION. You can destroy the user's session by calling the session_destroy function.

    Quote Originally Posted by George Morgan View Post
    Is this the techtuts user system?

    Change
    PHP Code:
    ob_start(); 
    to
    PHP Code:
    session_start(); 
    I wouldn't replace ob_start but just add session_start under it, session_start isn't a counterpart for ob_start. The function ob_start simply adds all the output (except headers) to a buffer and then sends ("flushes") the page's content to the user's computer at the end. The script might require ob_start is called, as if prior to an outputting function headers are set, you'll be returned with an error (you can't set headers after outputting data, hence why ob_start might have been called). However, the person who coded it originally may have just been an idiot and added it unnecessarily. [:
    Last edited by nets; 23-11-2006 at 03:11 PM.
    kinda quit.

  3. #13
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Teaspoon View Post
    Or infact it might even be: LEARN PHP!
    PHP Code:
    if (!isset($_SESSION)) {
      
    session_start();
    }
    $_SESSION['yoursessionnamehere'] == "What ever you want.. When ever you want..";
    $_SESSION['someothersession'] == $myvariable
    Rofl. Telling me to learn php.... Yeah very good Tom. Im suprised Henious didn't point out your mistake..

    I tested this and it doesn't work.

    Also, i love the bit about Dave being stuck up, it really made us laugh. Did you recall your humiliation in "Radio Panel Project" in the coding section..


    You have checked to see if a session is set before putting session_start();

    How the hell is it going to know if you havn't started the session?

    Not to mention you dont need == when setting values, == is used when comparing strings, and it makes it case sensitive.

    You are a clever chap

  4. #14
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    Rofl. Telling me to learn php.... Yeah very good Tom. Im suprised Henious didn't point out your mistake..

    I tested this and it doesn't work.

    Also, i love the bit about Dave being stuck up, it really made us laugh. Did you recall your humiliation in "Radio Panel Project" in the coding section..


    You have checked to see if a session is set before putting session_start();

    How the hell is it going to know if you havn't started the session?

    Not to mention you dont need == when setting values, == is used when comparing strings, and it makes it case sensitive.

    You are a clever chap
    Typo on the two =='s. Also the script does work.

    PHP Code:
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    ?>
    Does check to see if sessions are started... because if you start them twice you will get a error - it does not to see if a session is defined so please, shut up you PHP newbie.

    Also what humiliation in "Radio Panel Project" are you talking about :s

    Lets get some things clear here Mr. Know is all. You may think you know everything about PHP but in fact you do not so stop trying to make out you are the better of us because you'll only end up making enemies.

  5. #15
    Join Date
    Nov 2006
    Posts
    163
    Tokens
    0

    Default

    Tom is excellent at PHP. He is better than most of you, except carl, ect.

    So sthu, and learn sessions at PHP.NET

    (aimed at people dissing Tom)

  6. #16
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Teaspoon View Post
    Typo on the two =='s. Also the script does work.

    PHP Code:
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    ?>
    Does check to see if sessions are started... because if you start them twice you will get a error - it does not to see if a session is defined so please, shut up you PHP newbie.

    Also what humiliation in "Radio Panel Project" are you talking about :s

    Lets get some things clear here Mr. Know is all. You may think you know everything about PHP but in fact you do not so stop trying to make out you are the better of us because you'll only end up making enemies.
    Lol i don't think i know everything about php. Im not saying im better than everyone because im not, Henious and Carl are better than me (All i can think of atm)

    Yeah course it was a typo on the two =='s lol

    But why the hell did you put:

    PHP Code:
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    ?>
    Just tell me that then ill leave it..

  7. #17
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    Lol i don't think i know everything about php. Im not saying im better than everyone because im not, Henious and Carl are better than me (All i can think of atm)

    Yeah course it was a typo on the two =='s lol

    But why the hell did you put:

    PHP Code:
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    ?>
    Just tell me that then ill leave it..
    I told you.

    If session_start(); was called before it would give a error.. Basically its good coding practices and will prevent errors/warning even with E_ALL. Technically it is fine just to call session_start(); without first checking if session_start was called before.

  8. #18
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    righteo lets stop arguing lol.

    I've read somewhere that

    "Most coders hate each others way of coding"

    Anyway

    Lets stop now lol and soz for sounding know it all etc.

  9. #19
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    But why the hell did you put:

    PHP Code:
    <?php
    if (!isset($_SESSION)) {
      
    session_start();
    }
    ?>
    Basicly its a fail safe, it checks to see if a session varible exists, if not, it starts the session. If a session varible did exist on the other hand it would know it didnt need to declare a session, and hence avoide an error.

    There are circumstances this script may be nessary, aka if your writeing a script for distrbution which is exspected to be includeing in to its users own page and codeing. If the user was useing sessions without it, when included there would be errors, with it, its far more likly to run properly.

    On the other hand, in many situations, when a page is top level you know there are not going to be any sessions behind, in that case its really just a waste of code, and server resources (true a few bites bandwidth aint much, but after a billion page loads, it gona add up, so its good practise to code efficanly when possible :p)
    I have to admit these sorts of code bites, are a side effect of learning php in a detached way, aka knowing what will do what, while not actualy understanding whats going on in the language "/ Which mostly isnt a problem unless in more complex useage. You will notice alot of people use the scripts they learn of copieing orignaly, even when theres no use for them, when i orignal started with vb for exsample i would often use the with blabla statement to assign my varibles while in many cases there was no need and a simple dbtypeUsers.somepart would have been far more applicable

  10. #20
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by 01101101entor View Post
    in that case its really just a waste of code, and server resources (true a few bites bandwidth aint much, but after a billion page loads, it gona add up, so its good practise to code efficanly when possible :p)
    Lol, I would think nublets' iframes refreshing every 20 seconds would do that quite quick. After a billion page loads, most people would be out of bandwidth, because the rest of the script would be larger, + images and other pages, heh. (1.2tb of bandwidth owns pls)

    Oh, and Jackboy dude thing, I didn't pick up on the mistake because I wasn't really paying attention to the thread, just was reading it and noticed your post, which made me lol.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

Page 2 of 3 FirstFirst 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
  •