We help IT Professionals succeed at work.
Get Started

PHP Insert statment incorrect values

dsg138
dsg138 asked
on
143 Views
Last Modified: 2015-04-21
Experts,
I have some code where my users are required to choose a team.  There are 32 different buttons,, one for each team.
If the player chose team #5, the value "teamid" would be 5 and the following would be inserted into the DB:
-  UserID = 100 //for example
-  XMLID = l.mlb.com-t.5
-  WeekNum = 1  //if it were week #1

This would be a correct entry.  Most entries get successfully inserted.

Occasionally, I get the following added to my DB which is Incorrect and causes issues:
-  UserID = 100 //for example
-  XMLID = l.mlb.com-t.
-  WeekNum = 1  //if it were week #1
If this is added to my DB, it causes an issue since the user thinks their Team 5 went through, but it really didn't.

I'm not sure how this is possible since each of the buttons contains a different teamid.

Is there a way I can modify my code below so that the incorrect values never get inserted into my php database?

Code is below.  
Thanks,
-Dan

if( isset($_POST["teamid"]) ){

    $finalteam = "l.mlb.com-t." . $_POST["teamid"];
	
?>
<div class="notification success">
        <span></span>
        <div class="text">
        	<p><strong>Success!</strong> Your selection has been saved! </p>
        </div>
    </div>	
    
<?  

$PickID = $a4[XMLID];

$sql = "INSERT INTO RFTW_PICKS SET 
	UserID = '$MemberID',
	XMLID = '$finalteam',
	WeekNum = '$PickWeek'"
   			;
$sql = mysql_query($sql);

	}

Open in new window


Again, the above scenario is rare, but it's been happening now about 1% of the time.  I'm trying to isolate it and it possibly could be due to a mobile browser.  Any suggestions on how I can modify my statement?
Comment
Watch Question
Principal Data Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE