Problem with a MYSQL Query, PLS Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bsands
Forum Newbie
Posts: 3
Joined: Wed Dec 21, 2005 1:08 pm

Problem with a MYSQL Query, PLS Help

Post 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?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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
bsands
Forum Newbie
Posts: 3
Joined: Wed Dec 21, 2005 1:08 pm

Thank you

Post by bsands »

It works now. thank you for correcting my blunder.
Post Reply