Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    When I query my database:
    $result= mysql_query("SELECT * FROM users WHERE userName = '$username'");

    it is not responding correctly so I "echo"ed my $result and it gave me:
    Resource id #2


    Why would it do this?

  2.  

  3. #2
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Hmmmm I think it has something to do with the variable type and the way it is being called I am learning and had this problem also, fixed it though. If you could post more code as to what you are trying to do maybe I could help.

  4. #3
    Senior Member
    Join Date
    Aug 2011
    Posts
    217
    Member #
    29153
    Liked
    4 times
    I got it. I had to do something like:

    echo $result['userName'];

    or

    echo $result['2'];

    As far as the query not working, I don't remember what I did but it is now working.

  5. #4
    Senior Member Zboost's Avatar
    Join Date
    Apr 2011
    Location
    Houston
    Posts
    246
    Member #
    27459
    Liked
    20 times
    Ok then, glad you got it all figured out! :spin:

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,661
    Member #
    5580
    Liked
    713 times
    Do the query, as you did, and then put the results (fetch them) into an array.

    In your case, it should only find one row, unless you have the userName in multiple rows.

    $result= mysql_query("SELECT * FROM users WHERE userName = '$username'");
    while ($row = mysql_fetch_array($result)) {
    echo $row['userName']."<br />";
    }

    Some more discussion on fetch_array VS fetch_assoc ...
    http://php-tuts.blogspot.com/2008/11...tch-array.html



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:19 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com