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!


Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default php question +rep

    I have 3 files. a.php, b.php, and c.php. In each file I have require 'lol.php'. In lol.php I want to create a variable with the filename (either a.php, b.php, or c.php, not lol.php). Would I use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] or what? Or is there no predefined way variable for this?

    +rep to those who help.
    Vouches
    [x][x]

  2. #2
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    5,769
    Tokens
    1,249
    Habbo
    Beneficial

    Latest Awards:

    Default

    You can use any, although there are differences. Read up on them from here: http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm
    what is fetch gretchen?

  3. #3
    Join Date
    Nov 2008
    Location
    Cambridge, UK
    Posts
    901
    Tokens
    100

    Default

    basename(__FILE__);
    we're smiling but we're close to tears, even after all these years

  4. #4
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Quote Originally Posted by Beneficial View Post
    You can use any, although there are differences. Read up on them from here: http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm
    Thanks it worked.

    Quote Originally Posted by MattFr View Post
    basename(__FILE__);
    Didn't work. It showed lol.php instead of 1/2/3.php

    Also having another problem. I'm getting

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
    The code:

    PHP Code:
    $file htmlspecialchars($_SERVER['SCRIPT_NAME']);
    $query mysql_query(" SELECT * FROM tablename WHERE file = '$file' ");
    $count mysql_num_rows($query); 
    Database connection was done before the code. I can verify that the database and tables exist. Can't figure it out though.
    Vouches
    [x][x]

  5. #5
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    5,769
    Tokens
    1,249
    Habbo
    Beneficial

    Latest Awards:

    Default

    Fazon,

    Show me what happens when you use this code instead:

    PHP Code:
    $file htmlspecialchars($_SERVER['SCRIPT_NAME']);
    $query mysql_query(" SELECT * FROM tablename WHERE file = '$file' ") or die(mysql_error());
    $count mysql_num_rows($query); 
    what is fetch gretchen?

  6. #6
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Nevermind, figured it out. I didn't create the table/user. The guy who did doesn't know php/sql so he didn't give the mysql user any permissions.

    Thanks for your help though!
    Vouches
    [x][x]

  7. #7
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    5,769
    Tokens
    1,249
    Habbo
    Beneficial

    Latest Awards:

    Default

    It's alright, hit me up a PM if you get any other troubles!
    what is fetch gretchen?

  8. #8
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Yeah thanks, haven't coded a system in about a year.
    Vouches
    [x][x]

  9. #9
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    5,769
    Tokens
    1,249
    Habbo
    Beneficial

    Latest Awards:

    Default

    PHP isn't my strong point, but I help whenever I can
    what is fetch gretchen?

Posting Permissions

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