Problem with a MYSQL Query, PLS Help
Posted: Wed Dec 21, 2005 1:15 pm
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?
$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?