$pullItem = mysql_query("SELECT * FROM items WHERE item_id = '$itemid'");
while ($fetch = mysql_fetch_array($pullItem)) {
$statinc = $fetch['statinc'];
}
$pullUserStats = mysql_query("SELECT * FROM userstats WHERE user_id = '$uid'");
while ($fetch = mysql_fetch_array($pullUserStats)) {
$curstat = $fetch[$statinc];
}
mysql_query("UPDATE userstats SET $statinc=('$curstat' + '$incamount') WHERE user_id='$uid'"); //LINE 76
This is where I’m having trouble. I do have some coding in between, but my error is this:
“Notice: Undefined variable: curstat in ….. on line 76”
There are a few things wrong with the logic behind this code that make it seem like it’s either not coded to look like what it’s actually doing, or it’s just possibly not doing what you want it to do.
The first thing is that with the way you wrote the code, it looks like you want to loop through a bunch of results in the
whileloops, and when you get to the end of the loop,$statincis the value of the LAST result of the query.SELECT * FROM items WHERE item_id = '$itemid'suggests that you either have a bunch of items with the id fielditem_id, or you named what should possibly just be namedidasitem_id.If it’s the second case, your first query that loads the items should actually look like:
Which also means that your second query should look like this:
This leads me to believe that userstat is returning an empty query, and thus in your original code,
$curstatis never getting set.