have this code
[code=php]
$query = “select user.allienceid from user where user.username = ‘”.$_COOKIE[‘user’].”‘”;
echo $query; #prints select user.id from user where user.name = ‘name’
$result = querydatabase ($query); #see below
$allience = mysql_result($result, 0, “allienceid”);
echo $allience; #should print 1
this is the querydatabase ($query) function
[code=php]
function querydatabase ($query)
{
$db_host = ‘localhost’;
$db_name = ‘db_name’;
$db_user = ‘user’;
$db_pass = ‘password’;
mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name);
$result = mysql_query($query);
mysql_close();
return result;
}
Now I know that the connection works. and when I run the query in phpmyadmin I get a value of 1.
but when I echo $allience nothing prints out can anybody figure out what I am doing wrong?