I am trying to write a code where the User has multiple characters and the User can see their characters ranking based on their character's levels. The characters are all on the same table and the setup for the table is basically:

ID-CharacterID-CharacterName-CharacterLevel

The problem with the code below is it gives me an syntax error, unexpected '1'(T_DNUMBER)

below is the code in PDO: (thanks in advance for any help):

<?php    

if(isset($_POST['submit']))
{


$q = $conn->prepare("SELECT `charactername` FROM `users` WHERE id = :id ORDER BY
`characterlevel` DESC");
$q ->bindParam(':id', $sessionid , PDO::PARAM_INT);
$q->execute();

$rank = 0;
$last_score = false;
$rows = 0;

while ($row = $q->fetch(PDO::FETCH_ASSOC)) 
$rows++;
if( $last_score!= $row['point'] ){
$last_score = $row['point'];
$rank = $rows;
}echo "rank ".$rank." is ".$row['charactername']." with the age of ".$row['age'].";
}
?>
<br />
<form action="1.php" method="POST">
<input type = "submit" name="submit" value= "submit"
</form>
有帮助吗?

解决方案

Unbalanced ":

echo "rank ".$rank." is ".$row[snip]." with the age of ".$row['age'].";
     ^-1---^       ^-2--^            ^--------3--------^             ^---?
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top