Unforgiven wrote:$weapon = mysql_query("SELECT Weapons.Name FROM Weapons, Members WHERE Members.Weapon='Weapons.id' and Members.Username = '$Username';");
That query returns Resource ID #5, when it should be returning a string.
Your analysis that it "should be" returning a string is incorrect. According to the docs
, mysql_query() "should be" returning a resource, and that appears to be the case. Now you need to fetch the result of that query by passing the name of the resource to mysql_fetch_array()
- Code: Select all
$weapon = mysql_query('SELECT Weapons.Name FROM Weapons, Members WHERE Members.Weapon=Weapons.id and Members.Username = \'' . $Username. '\'');
$weapon_array = mysql_fetch_assoc($weapon);
This will populate $weapon_array with the returned row. Note that if you expect the query to return more than one row, you'll want to place mysql_fetch_assoc() a while() loop or similar. Refer to the docs for help with the usage. Also note that I cleaned up your syntax a bit. I could lecture people on syntax, legibility, optimization, conventions, etc., but for your sake I won't. Enjoy.