View Full Version : calling on a mysql query & session through php

11-19-2006, 05:54 PM
$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

11-19-2006, 08:13 PM
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.

11-19-2006, 10:53 PM
The value does exist. I'm going to try and do what you said, but I'm not fully understanding it..