How To Use $count!

php

#1

Sorry If is wrong category.

So i want to make one XP counter for a game,
and i search on google about this, and i found this

<?php

$username ="Raw"
$count = 287;
$lvl = 1;
if ($count >= 12800){$lvl = 10;}
else if ($count >= 6400){$lvl = 9;}
else if ($count >= 3200){$lvl = 8;}
else if ($count >= 1600){$lvl = 7;}
else if ($count >= 800){$lvl = 6;}
else if ($count >= 400){$lvl = 5;}
else if ($count >= 200){$lvl = 4;}
else if ($count >= 100){$lvl = 3;}
else if ($count >= 50){$lvl = 2;}
echo "$username is level $lvl with $count points";

If i try to use like this i’ll get one error

Parse error: syntax error, unexpected '$count' (T_VARIABLE) (Line 3 on $count)

if i edit line 3 like this .$count = 287;
i’ll get this
Raw287 is level 4 with 287 points
Looks good btw Raw287 287 at my name is wrong!
so any idea how can i fix this?!


#2

You are missing a semicolon in the 2nd line of your code.

You have

$username ="Raw"

but you ned

$username ="Raw";

Best,
Michael


#3

thanks! :slight_smile: