Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Profile Page

  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts

    Profile Page

    Does anyone have an easy script to make a profile page using php/mysql, preferably one that uses phpbb3 account info. Iv looked at alot of scipts for this but none of them are working for me.

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    None that I know of for phpbb3, but writing a script is easy. As long as you know where the data is, in the db rows all it takes is one file. Something like:

    This is example a profile URL would be http://site.com/forum/profile.php?u=UserName

    PHP Code:
    <?php
    #This file is profile.php

    if (isset($_GET['u']))
    {
       
       
    $username mysql_real_escape_string(trim($_GET['u']));
       
    $mq mysql_query("SELECT * FROM `users` WHERE `username` = $username") or die('Mysql Error: ' mysql_error());
       
        if (
    mysql_num_rows($mq) < 1)

        {
           echo 
    'That user doesn\'t exist';
        }

        else

        {
         
        
    $row mysql_fetch_assoc($mq);

        
    //Now we're ready to display information
        
    echo '<h1>' $row['username'] . '</h1>';
        echo 
    '<div style="margin-top:10px">Age:'.$row['age'].'</div>';
        
    //etc all the html and whatnot would go here to display the information
        
    }



    }
    ?>
    So in this example we turned the database info into an associative array so $row is the name of the array and the informatin in the brackets are the key which will return a value, in mysql, the key would be the row name, so if we use $row['age'] it will return the value in the age field with the set criteria of the mysql query above.

    So you'll just need to change the mysql_query in this example and it should work.
    Last edited by Zangeel; 07-28-2009 at 10:28 PM.

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    I get this error:

    Edit:

    Fatal error: Cannot redeclare deregister_globals() (previously declared in /home/*****/public_html/Home/phpBB3/common.php:32) in /home/******/public_html/Home/phpBB3/common.php on line 94

    This is the error I ussually get


    Also, This might sound stupid, but to open this I would use
    <a href="what?">name</a>
    Last edited by Ndogg; 07-28-2009 at 11:08 PM.

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Try putting the profile.php behind the forum folder, so its in the root.

    And to link someone to their profile it would be

    Code:
    <a href="profile.php?u=UsernameHere">Profile</a>
    Now lets say you want to display the link on individual forum posts, find the piece of code that displays the username and echo it like

    PHP Code:
    echo '<a href="profile.php?u=' $CodeForUsername '">Profile</a>'

  • #5
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    Thanks, but now the page is just blank?

    Edit:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''phpbb_users' WHERE 'username' = Ndogg' at line 1
    Last edited by Ndogg; 07-29-2009 at 12:32 AM.

  • #6
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    The only way the page would be blank is if you went to the page directly like

    site.com/profile.php

    What you need to do is go to it like

    site.com/profile.php?u=YourUsernameHere

    This way it'll take the variable from the URL run it thru mysql, and if it's a user display the information (and if it's not a user then it will display 'User doesn't exist') So lets say your username is "Admin" your profile would be

    http://site.com/profile.php?u=admin

  • #7
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts

  • #8
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Post the SQL query you used, the syntax is just off I'd need to see it.

  • Users who have thanked Zangeel for this post:

    Ndogg (07-29-2009)

  • #9
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    $mq = mysql_query("SELECT * FROM 'phpbb_users' WHERE 'username' = $username") or die(mysql_error());

  • #10
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    In the mysql database, when you look under phpbb_users is the row that has the username called username? or user? becaues that may be the issue here, make sure the row name is correct, because it might be simple like needing to change it to

    PHP Code:
    "SELECT * FROM `phpbb_users` WHERE `user` = ' " $username" ' " 

  • #11
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    It is username...

  • #12
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    OK try using back sticks like I used

    PHP Code:
    $mq mysql_query("SELECT * FROM `phpbb_users` WHERE `username` = '" .  $username "'") or die(mysql_error()); 

  • Users who have thanked Zangeel for this post:

    Ndogg (07-29-2009)

  • #13
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    According to this tutorial:

    SELECT *
    FROM orders
    WHERE customer = 'Tizag'

    it should work, and I set my code to this way but it still says the same thing, I think its because of the $username

  • #14
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    OMG! Im an idiot!

    This: '
    Is not
    This: `

  • #15
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    $mq = mysql_query('SELECT * FROM phpbb_users WHERE username=\''.$username.'\'') or die(mysql_error());


  •  
    Page 1 of 2 12 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
    •