0

Database: motion_world
table: accounts
columns: id | username | password | register_date | account_level

When i go into HeidiSQL -> Query
and write:

SELECT account_level FROM accounts WHERE username='Sha11e'

it returns: administrator


But if I, in a PHP file, write:

mysql_connect("localhost","root","");
mysql_select_db("motion_world");

$hi = mysql_query("SELECT account_level FROM accounts WHERE username='Sha11e'");

echo $hi;

I get: Resource Id #3

What the hell? :s

Edited by sha11e: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by psycode
0

You must first process the result by using mysql_fetch_array() function, then you can work with data returned from query. This function will return an array containing records, if there is a single record, you could write:

$record = mysql_fetch_array($hi,MYSQL_ASSOC);

And access data:

echo $record["account_level"];

If there are more records:

while ($rec=mysql_fetch_array($hi,MYSQL_ASSOC)) {
    echo $rec["account_level"];
}

I recommend you to study and practice with this function:

Reference to mysql_fetch_array()

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.