Switch17
03-20-2004, 03:41 PM
I'm trying to have an sql query return a result. Then to compare that result to another variable, and if the result matches the variable, then to proceed, and if not to indicate an error message. I'm still new to php and sql, but believe I'm making some progress in learning this.
Here is the code i' currently have: //========================================
// Get Team Identity and Proceed
//========================================
$PnTeamID = pnUserGetVar("_TEAM_ID");
$sql = "SELECT T.name, T.Team_ID FROM $TEAMS as T, $DRAFT_ORDER AS D WHERE
D.Team_ID = T.Team_ID AND D.season = $SEASON AND D.overall_pick = $overpick";
$result = mysql_query($sql);
$team_id = $row[1];
if ($team_id = $PnTeamID)
{
$row = mysql_fetch_row($result);
$team_name = $row[0];
}
else
{
//FATAL ERROR, This is not your team
include ("football/mots/includes/page_header.php");
echo ("Sorry, You are trying to access another teams information");
include ("football/mots/includes/page_footer.php");
exit;
}
I had thought that would work, but its still letting you access any of my teams information, when it should be restricting you to your own team. So if the PNTeamID matches the query, then to proceed, and if not, then give the error. At least thats what I think I need to do.
Here is the code i' currently have: //========================================
// Get Team Identity and Proceed
//========================================
$PnTeamID = pnUserGetVar("_TEAM_ID");
$sql = "SELECT T.name, T.Team_ID FROM $TEAMS as T, $DRAFT_ORDER AS D WHERE
D.Team_ID = T.Team_ID AND D.season = $SEASON AND D.overall_pick = $overpick";
$result = mysql_query($sql);
$team_id = $row[1];
if ($team_id = $PnTeamID)
{
$row = mysql_fetch_row($result);
$team_name = $row[0];
}
else
{
//FATAL ERROR, This is not your team
include ("football/mots/includes/page_header.php");
echo ("Sorry, You are trying to access another teams information");
include ("football/mots/includes/page_footer.php");
exit;
}
I had thought that would work, but its still letting you access any of my teams information, when it should be restricting you to your own team. So if the PNTeamID matches the query, then to proceed, and if not, then give the error. At least thats what I think I need to do.