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.
Results 1 to 3 of 3
  1. #1
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calling on a mysql query & session through php

    PHP Code:
    $checkclass $db_object->query("SELECT class FROM table_a WHERE username = '".$_SESSION['username']."'"); 
    I am trying to call on a table from my mysql database, and tell it to use the current session's username to pull out the users class. It won't work though. Whenever I call on $checkclass it says Object, and thats all.

    Any help would be greatly appreciated

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    To narrow down the problem, try and echo out the value of $_SESSION['username'];

    Check that the value exists in the database,

    Also, I think when you execute the query statement, the returned value is a resource or an object. for example,

    // result is of type resource
    $result = mysql_query( $sql );
    // to do anything with the result, we need to obtain values
    // by using the following
    while( $row = mysql_fetch_array( $result ) ) {
    // obtain data from array $row.
    }


    good luck.
    Ess

  • #3
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The value does exist. I'm going to try and do what you said, but I'm not fully understanding it..


  •  

    Posting Permissions

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