Page 1 of 1

Problem with a MYSQL Query, PLS Help

Posted: Wed Dec 21, 2005 1:15 pm
by bsands
I am having a problem with a login script. I am trying to pull up the type of account set to a user and have the script redirect them to a specific page based on the account type. The problem I run into is that the SQL query is pulling up, "Resource ID #4" instead of the account type 0. This is the code I am using:

$search_acctype="SELECT account FROM accounts WHERE username='$accname'";
$result_acctype=mysql_query($search_acctype);

$search_accid="SELECT id FROM accounts WHERE username='$accname'";
$result_accid=mysql_query($search_accid);

//Set Session Variables
$_SESSION[auth] = 1;
$_SESSION[acc_type] = $result_acctype;
$_SESSION[online_time] = time()+900;
$_SESSION[acc_id] = $result_accid;


if( $result_acctype == 0)
{
header( "Location: http://www.snowburst-tech.com/writermain.php");
echo "Test writer" . $result_acctype;
exit;
}
elseif( $result_acctype == 1)
{
header( "Location: http://www.snowburst-tech.com/publishermain.php");
exit;
echo "Test Publisher" . $result_acctype;
}
elseif( $result_acctype == 3)
{
header( "Location: http://www.snowburst-tech.com/adminmain.php");
exit;
echo "Test Admin" . $result_acctype;
}
else
{ echo "Broken" . $result_acctype; }



----------------------------------------------------------------------------------------------------

Can anyone look at this and tell me why my query doesn't give me the account type but rather a resource ID?

Posted: Wed Dec 21, 2005 1:24 pm
by josh
you need to retreive the value from the mysql resource
http://www.php.net/mysql_result works good for single values
http://www.php.net/mysql_fetch_array for many values is generally what you would use

Thank you

Posted: Wed Dec 21, 2005 1:29 pm
by bsands
It works now. thank you for correcting my blunder.