Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Connection to table

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default Connection to table

    How do you use PHP to retrieve user data stored in a table? i.e.:

    THE TABLE: 'SomethingRather.exe'
    ------------------------------------
    NAME | PASSWORD | ACCESS LEVEL |
    ------------------------------------
    NAME2|PASSWORD2|ACCESS LEVEL2|
    ------------------------------------
    NAME3|PASSWORD3|ACCESS LEVEL3|
    ------------------------------------

    Say I want to find NAME2's password and access level. What do I do? And here is the catch: I need to search through the users to find the one I want. i.e. they type Name2 and I need to find their password, etc.

    Anyone?

    Thanks
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Have you tried to use this query?

    Code:
    SELECT * FROM `table` WHERE `NAME`='NAME2'
    Of course, you will have to substitue the above to work with your code.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Quote Originally Posted by thetestingsite View Post
    Have you tried to use this query?

    Code:
    SELECT * FROM `table` WHERE `NAME`='NAME2'
    Of course, you will have to substitue the above to work with your code.
    Hope this helps.

    I don't know what that is. Can you explain it better?

    >>>>>>>>>SORRY THIS POSTED TWICE. My IE messed up. . .
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    In your PHP code, try using the query that I posted above.

    Example:
    Code:
    <?php
    
    $name = $_REQUEST['name'];
    
    include('dbconnect.php'); //this will open the connection to the database
    
    $info = mysql_query("SELECT * FROM `tableNameHere` WHERE `NAME`='$name'");
    
    while ($qry = mysql_fetch_array($info)) {
      echo $qry['password'];
    }
    ?>
    Basically what the above does is search through the database and returns results of the rows in the table that the column "NAME" matches to the variable "$name". After it gets the results, we assign the variable $qry to fetch the array of each row, and print the password for each name (that gets returned) onto the screen.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    I think I get it, but is there some kind of tutorial on the subject that I can study? I've been looking on google, but I'm not entirely sure what to look for. . .
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    That's a PHP example of working with a MySql database. I'm hoping you know what PHP is, and how to use it, because here's a great PHP/MySql tut.
    http://php-mysql-tutorial.com/

    It'll show you the basic MySql command lines and how to use them with PHP.
    - Mike

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    EDIT: Sorry Mike, cross-posted.
    Happens to me all the time , no prob.

    Also:
    http://www.freewebmasterhelp.com/tutorials/phpmysql
    I found that one useful.
    - Mike

  9. #9
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thank you, mburt and thetestingsite! I'll check out those sites and see what I can dig up.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  10. #10
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    ARGH! I REALLY don't want to have to do all of that. . . Is there no way to not use MySQL and just use the table directly?
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

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
  •