AFAIK, none of the MySQL functions return objects. Any code of the form $varname->whatever is therefore incorrect (unless you're using an object-based data abstraction layer library, which you're not).
Here is how you create a MySQL connection, issue a query, and then iterate through each record in the resultset:
$dbconn = mysql_connect( $hostname, $username, $password );
mysql_select_db( $dbname, $dbconn );
$query = "SELECT * FROM whatever";
$resultset = mysql_query( $query, $dbconn );
// iterate through each row in the resultset
while ( $row = mysql_fetch_array( $resultset ) ) {
// do something with this record
// for example:
echo $row["column1name"] . ', ' . $row["column2name"] . '<br />';
}