Parse error: syntax error, unexpected '}'
Résolu
Spyk0
Messages postés
36
Date d'inscription
Statut
Membre
Dernière intervention
-
nico3009 Messages postés 103 Date d'inscription Statut Membre Dernière intervention -
nico3009 Messages postés 103 Date d'inscription Statut Membre Dernière intervention -
Bonjour, a tous j'ai un problème avec du php j'ai l'erreur suivante : Parse error: syntax error, unexpected '}' in /www/tydus/newscore.php on line 1
et voici le code du fichier :
<?php
}
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
// This is a fix for var "score" wich is send as "Score" and not as "score" like in game "Easter Egg Catch"
if(empty($score))
{
$score = $HTTP_POST_VARS['Score'];
}
if(!empty($game_name) && !empty($score))
{
// Find Topscore
$sql = 'SELECT rank_topscore, rank_score FROM '.$db->prefix.'arcade_ranking, '.$db->prefix.'users WHERE rank_player = '.$db->prefix.'users.id AND rank_game = "'.$game_name.'" ORDER BY rank_score DESC LIMIT 1';
$query = $db->query($sql) or error("Impossible to select topscore.", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_topscore'] = 1 && $line['rank_score'] < $score)
{
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_topscore = '.$topscore.' WHERE rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update the topscore", __FILE__, __LINE__, $db->error());
$topscore = 1;
}
elseif($line['rank_topscore'] >= 0 && $line['rank_score'] <= $score)
{
$topscore = 1;
}
else
{
$topscore = 0;
}
$sql = 'SELECT * FROM '.$db->prefix.'arcade_ranking WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the user and game", __FILE__, __LINE__, $db->error());
if(mysql_num_rows($query) > 0)
{
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= $score)
{
// Update new highscore
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_score = '.$score.', rank_date = '.$now.' , rank_topscore = '.$topscore.' WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update new highscore", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
else
{
// No new highscore
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_play.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
// Is there a score?
$sql = 'SELECT rank_score, rank_topscore FROM '.$db->prefix.'arcade_ranking WHERE rank_game = "'.$game_name.'" ORDER BY rank_score DESC, rank_topscore DESC';
$query = $db->query($sql) or error("Impossible to select the topscore", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= 0 && $line['rank_topscore'] <= 0)
{
$topscore = 1;
}
// Add new Highscore
$sql = 'INSERT INTO '.$db->prefix.'arcade_ranking (rank_game, rank_player, rank_score, rank_topscore, rank_date) VALUES ("'.$game_name.'", '.$pun_user['id'].', '.$score.', '.$topscore.', '.$now.')';
$query = $db->query($sql) or error("Impossible to insert the new score", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
error($lang_common['No permission']);
}
?>
Merci d'avance
et voici le code du fichier :
<?php
}
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
// This is a fix for var "score" wich is send as "Score" and not as "score" like in game "Easter Egg Catch"
if(empty($score))
{
$score = $HTTP_POST_VARS['Score'];
}
if(!empty($game_name) && !empty($score))
{
// Find Topscore
$sql = 'SELECT rank_topscore, rank_score FROM '.$db->prefix.'arcade_ranking, '.$db->prefix.'users WHERE rank_player = '.$db->prefix.'users.id AND rank_game = "'.$game_name.'" ORDER BY rank_score DESC LIMIT 1';
$query = $db->query($sql) or error("Impossible to select topscore.", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_topscore'] = 1 && $line['rank_score'] < $score)
{
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_topscore = '.$topscore.' WHERE rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update the topscore", __FILE__, __LINE__, $db->error());
$topscore = 1;
}
elseif($line['rank_topscore'] >= 0 && $line['rank_score'] <= $score)
{
$topscore = 1;
}
else
{
$topscore = 0;
}
$sql = 'SELECT * FROM '.$db->prefix.'arcade_ranking WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the user and game", __FILE__, __LINE__, $db->error());
if(mysql_num_rows($query) > 0)
{
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= $score)
{
// Update new highscore
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_score = '.$score.', rank_date = '.$now.' , rank_topscore = '.$topscore.' WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update new highscore", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
else
{
// No new highscore
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_play.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
// Is there a score?
$sql = 'SELECT rank_score, rank_topscore FROM '.$db->prefix.'arcade_ranking WHERE rank_game = "'.$game_name.'" ORDER BY rank_score DESC, rank_topscore DESC';
$query = $db->query($sql) or error("Impossible to select the topscore", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= 0 && $line['rank_topscore'] <= 0)
{
$topscore = 1;
}
// Add new Highscore
$sql = 'INSERT INTO '.$db->prefix.'arcade_ranking (rank_game, rank_player, rank_score, rank_topscore, rank_date) VALUES ("'.$game_name.'", '.$pun_user['id'].', '.$score.', '.$topscore.', '.$now.')';
$query = $db->query($sql) or error("Impossible to insert the new score", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
error($lang_common['No permission']);
}
?>
Merci d'avance
A voir également:
- Parse error: syntax error, unexpected '}'
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Playback error reconnect in 3s (1/5) francais - Forum Box et Streaming vidéo
- Whea error occt - Forum Processeur
- Error 1962 ✓ - Forum PC fixe
- A javascript error occurred in the main process - Forum Matériel & Système
19 réponses
Merci de vos conseilles j'ai refait le code mais l'erreur :
Parse error: syntax error, unexpected '}' in /www/tydus/newscore.php on line 8
Pourtant j'ai fait comme vous m'avez dit
Voici le code :
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
// This is a fix for var "score" wich is send as "Score" and not as "score" like in game "Easter Egg Catch"
if(empty($score))
{
$score = $HTTP_POST_VARS['Score'];
}
if(!empty($game_name) && !empty($score))
{
// Find Topscore
$sql = 'SELECT rank_topscore, rank_score FROM '.$db->prefix.'arcade_ranking, '.$db->prefix.'users WHERE rank_player = '.$db->prefix.'users.id AND rank_game = "'.$game_name.'" ORDER BY rank_score DESC LIMIT 1';
$query = $db->query($sql) or error("Impossible to select topscore.", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_topscore'] = 1 && $line['rank_score'] < $score)
{
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_topscore = '.$topscore.' WHERE rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update the topscore", __FILE__, __LINE__, $db->error());
$topscore = 1;
}
elseif($line['rank_topscore'] >= 0 && $line['rank_score'] <= $score)
{
$topscore = 1;
}
else
{
$topscore = 0;
}
$sql = 'SELECT * FROM '.$db->prefix.'arcade_ranking WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the user and game", __FILE__, __LINE__, $db->error());
if(mysql_num_rows($query) > 0)
{
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= $score)
{
// Update new highscore
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_score = '.$score.', rank_date = '.$now.' , rank_topscore = '.$topscore.' WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update new highscore", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
else
{
// No new highscore
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_play.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
// Is there a score?
$sql = 'SELECT rank_score, rank_topscore FROM '.$db->prefix.'arcade_ranking WHERE rank_game = "'.$game_name.'" ORDER BY rank_score DESC, rank_topscore DESC';
$query = $db->query($sql) or error("Impossible to select the topscore", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= 0 && $line['rank_topscore'] <= 0)
{
$topscore = 1;
}
// Add new Highscore
$sql = 'INSERT INTO '.$db->prefix.'arcade_ranking (rank_game, rank_player, rank_score, rank_topscore, rank_date) VALUES ("'.$game_name.'", '.$pun_user['id'].', '.$score.', '.$topscore.', '.$now.')';
$query = $db->query($sql) or error("Impossible to insert the new score", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
error($lang_common['No permission']);
}
?>
Parse error: syntax error, unexpected '}' in /www/tydus/newscore.php on line 8
Pourtant j'ai fait comme vous m'avez dit
Voici le code :
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
// This is a fix for var "score" wich is send as "Score" and not as "score" like in game "Easter Egg Catch"
if(empty($score))
{
$score = $HTTP_POST_VARS['Score'];
}
if(!empty($game_name) && !empty($score))
{
// Find Topscore
$sql = 'SELECT rank_topscore, rank_score FROM '.$db->prefix.'arcade_ranking, '.$db->prefix.'users WHERE rank_player = '.$db->prefix.'users.id AND rank_game = "'.$game_name.'" ORDER BY rank_score DESC LIMIT 1';
$query = $db->query($sql) or error("Impossible to select topscore.", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_topscore'] = 1 && $line['rank_score'] < $score)
{
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_topscore = '.$topscore.' WHERE rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update the topscore", __FILE__, __LINE__, $db->error());
$topscore = 1;
}
elseif($line['rank_topscore'] >= 0 && $line['rank_score'] <= $score)
{
$topscore = 1;
}
else
{
$topscore = 0;
}
$sql = 'SELECT * FROM '.$db->prefix.'arcade_ranking WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the user and game", __FILE__, __LINE__, $db->error());
if(mysql_num_rows($query) > 0)
{
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= $score)
{
// Update new highscore
$sql = 'UPDATE '.$db->prefix.'arcade_ranking SET rank_score = '.$score.', rank_date = '.$now.' , rank_topscore = '.$topscore.' WHERE rank_player = '.$pun_user['id'].' AND rank_game = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to update new highscore", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
else
{
// No new highscore
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_play.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
// Is there a score?
$sql = 'SELECT rank_score, rank_topscore FROM '.$db->prefix.'arcade_ranking WHERE rank_game = "'.$game_name.'" ORDER BY rank_score DESC, rank_topscore DESC';
$query = $db->query($sql) or error("Impossible to select the topscore", __FILE__, __LINE__, $db->error());
$line = $db->fetch_assoc($query);
if($line['rank_score'] <= 0 && $line['rank_topscore'] <= 0)
{
$topscore = 1;
}
// Add new Highscore
$sql = 'INSERT INTO '.$db->prefix.'arcade_ranking (rank_game, rank_player, rank_score, rank_topscore, rank_date) VALUES ("'.$game_name.'", '.$pun_user['id'].', '.$score.', '.$topscore.', '.$now.')';
$query = $db->query($sql) or error("Impossible to insert the new score", __FILE__, __LINE__, $db->error());
$sql = 'SELECT game_id FROM '.$db->prefix.'arcade_games WHERE game_filename = "'.$game_name.'"';
$query = $db->query($sql) or error("Impossible to select the game", __FILE__, __LINE__, $db->error());
$gameid = $db->fetch_assoc($query);
echo '<script type="text/javascript">window.location= "arcade_ranking.php?id='.$gameid['game_id'].'"</script>';
}
}
else
{
error($lang_common['No permission']);
}
?>
Ton mesage d'erreur veut dire :
syntax error = erreur de syntaxe (écriture au niveau du script)
unexpected '}' = } innatendue on va dire. Il ne comprend pas ce que vient faire cette accolade.
on line 1 = à la ligne 1
syntax error = erreur de syntaxe (écriture au niveau du script)
unexpected '}' = } innatendue on va dire. Il ne comprend pas ce que vient faire cette accolade.
on line 1 = à la ligne 1
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Ouvre ton accolade au début au lieu de la supprimer sinon à la ligne 8 tu auras encore une accolade fermée toute seule.
Le probleme c'est que je ne voit aucune accolade qui se ferme sans s'ouvrir et si je met { au debut sa refait la meme erreur que le premier code :( merci d'avence
Le début de ton code est :
<?php
}
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
Il faut que tu l'écrives comme ça :
<?php
{
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
<?php
}
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
Il faut que tu l'écrives comme ça :
<?php
{
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
J'ai mit comme tu m'a dit mais il y a toujours l'erreur Parse error: syntax error, unexpected '}' in /www/tydus/newscore.php on line 6
<?php
{
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
Voila ^^
{
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
Voila ^^
Si tu as
unexpected '}' in /www/tydus/newscore.php on line 6
c'est qu'à priori tu n'as pas rechargé ta page.
Mais en fait je ne suis pas sur qu'il faille l'accolade ouverte ici.
Recharge d'abord ta page et sinon ouvre ton accolade avant error
unexpected '}' in /www/tydus/newscore.php on line 6
c'est qu'à priori tu n'as pas rechargé ta page.
Mais en fait je ne suis pas sur qu'il faille l'accolade ouverte ici.
Recharge d'abord ta page et sinon ouvre ton accolade avant error
J'ai recharger la page XD j'ai fait comme tu m'a dit mais toujours l'erreur donc sa me gonfle un peut ^^ je ne voit pas pourquoi il mes l'erreur
Toujours "on line 6" dans ton message d'erreur??
Sinon tu as bougé ton accolade ouverte là où je t'ai dit?
Sinon tu as bougé ton accolade ouverte là où je t'ai dit?
Ouep toujours en ligne 6 et j'ai mit comme tu m'a dit
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
{error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_id'] == PUN_GUEST)
{error($lang_common['No permission']);
}
// Recover the game name and the score
$game_name = $HTTP_POST_VARS['game_name'];
// str_replace strips all spaces present in the score string
$score = str_replace(" ", "", $HTTP_POST_VARS['score']);
$topscore = 1;
$now = time();
Y a un truc bizarre quand même :-)))
Tu as enlevé les accolades et il te donne une erreur d'accolade à la 6 !!!!!
As tu bien :
- enregistré ta page après modif
- renvoyer ta page en ftp
- recharger ta page
?
Tu as enlevé les accolades et il te donne une erreur d'accolade à la 6 !!!!!
As tu bien :
- enregistré ta page après modif
- renvoyer ta page en ftp
- recharger ta page
?