PDA

View Full Version : submits informtion twice when not supposed to


duniyadnd
10-07-2002, 08:42 PM
The problem is that whenever a new entry is submitted in, it takes in the value twice and I got two identical entries. This is a "forwarding" page, the page where once a command is processed, it goes to this page. Updates work fine, as do deletes (not shown), but when a new entry is submitted, it adds it twice. Wonder if anyone would see why.

Also, the previous page where you submit information in, there are no SQL queries on that page, so it can't be adding on from that one, in fact, I tried sending the information to another page (not this one) and it doesn't add any information from that page whatsoever, so I figure its from this page.

Removed most of the code from the page, so if anyone has any idea, or suggestions, would appreciate it.

Thanks,
Duniyadnd

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

<?

include '../inc/db.inc';
include '../inc/confirm.inc';

/* spit out values */

echo "clubID:" . $clubID. "<br />";
echo "clubName:" . $clubName. "<br />";
echo "leagueID:" . $leagueID. "<br />";

/* calling in the clubID from the one entered in the last page */

$Query = "SELECT clubID FROM club WHERE clubID = '$clubID'";

$r = mysql_query($Query);
$row = mysql_fetch_array($r);

echo "$row";

/* if the ClubID already exists, update */

if ($row != NULL)

{
$Query = "UPDATE club SET " .
"clubID = \" $clubID \", ".
"clubName= \" $clubName \", ".
"leagueID= \" $leagueID \" ".
"WHERE clubID = '$clubID' ";
echo "<br /><b>Updating<br /></b>";
}

/* otherwise insert as a new entry */
else if ($row == NULL)
{
$Query = "INSERT INTO club ";
$Query.= "VALUES (NULL, ";
$Query.= "'$clubName', ";
$Query.= "'$leagueID')";
echo "<b>Inserting<br /></b>";
}

?>

duniyadnd
10-13-2002, 10:34 PM
Might as well answer my own question..

I did not need the following lines:


$r = mysql_query($Query);
$row = mysql_fetch_array($r);

echo "$row";


Needless to say, I had to replace $row in the if statements to other variables.

Duniyadnd