Php equal more or less operators -
i getting following error:
$experience = $row[experience]; use of undefined constant experience - assumed 'experience' – user3696343 )
from code:
} else if($_get['event'] == 15) { $fetch = mysqli_query($db_handle, "select gold, bank, troop, head, body, gloves, foot, combatlog, item0, item1, item2, item3, coordinatex, coordinatey, coordinatez, horse, hp, new, food, experience, level playerdata unique_id = '$unique_id'"); $row = mysqli_fetch_assoc($fetch); $experience = $row[experience]; $xptolevel = '50'; if($experience >= $xptolevel) { echo'enough xp level up'; mysqli_query($db_handle, "update playerdata set experience = 0, level = level + 1 unique_id = '$unique_id'"); echo "15|$unique_id|$local_id|$row[gold]|$row[bank]|$row[troop]|$row[head]|$row[body]|$row[gloves]|$row[foot]|$row[combatlog]|$row[item0]|$row[item1]|$row[item2]|$row[item3]|$row[coordinatex]|$row[coordinatey]|$row[coordinatez]|$row[horse]|$row[hp]|$row[new]|$row[food]|$row[level]|$row[experience]|"; } else { echo'not enough xp level up'; } }
i hope can help
when access associative array element, add quotes:
$row[experience] becomes $row['experience']
if use experience, assumes trying use constant experience doesn't exist php converts string you. works, notice.
if need use within quotes, use {}
around it:
echo "some string {$row['experience']}";
finally, sql code not safe. use parametrized queries instead of injecting actual variables in sql.
Comments
Post a Comment