Parse error: syntax error, unexpected ';'

Résolu/Fermé
parvn Messages postés 49 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 7 mai 2012 - 9 août 2009 à 20:26
lewis34 Messages postés 2557 Date d'inscription samedi 21 juillet 2007 Statut Membre Dernière intervention 30 mai 2015 - 9 août 2009 à 21:34
Bonjour,
J'ai desinstaller mon easyphp a cause de certain probleme, la apres l'avoir reinstaller, en essayant d'executer les codes des programmes qui marchaient tres bien avant, rien ne marche plus il m'envoie des message erreur insense que je comprend pas par exemple pour ce code:
usefulfunc.php il m'envoie le message d'erreur suivant

Parse error: syntax error, unexpected ';' in C:\Program Files\EasyPHP 2.0b1\www\training\application\usefulfunc.php on line 6

alors que a la ligne 6 il y'a just un commentaire.

voici le code usefulfunc.php qui contient des functions que j'utulise dans mes codes en se cas je l'inclu dans mon code sign.php qui suit just apres usefulfunc.php et c'est donc en appelant sign.php que le message d'erreur si dessus s'affiche.

usefulfunc.php

<?php
include ("basic.php");
include ("charset.php");
// global limit
$limit = 2;
// this function print the HTML input field

function print_input_fields()
{
$fields = func_get_args();
while (list(,$field) = each($fields))
{
print " <tr>\n";
print " <td valign=top align=right><b>".ucfirst($field).":</b></td>\n";
print " <td valign=top align=left><input type=text name=$field size=40></td>\n";
print " </tr>\n\n";
}
}



// this function print entries that have been enter in the guestbook
function print_entry($row,$preserve = ""){
$numargs=func_num_args();
for($i = 2; $i < $numargs; $i++) {
$field = func_get_arg($i);
// This will transform a label string to a valid database
// field name - e.g., "Last Name" becomes "last_name"
$dbfield = str_replace(" ", "_", strtolower($field));
$dbvalue=cleanup_text($row[$dbfield],$preserve);
$name = ucwords($field);
print " <tr>\n";
print " <td valign=top align=right><b>$name:</b></td>\n";
print " <td valign=top align=left>$dbvalue</td>\n";
print " </tr>\n\n";
}
}

// to insert entries in the guestbook database
function create_entry($name,$location,$email,$url,$comments){
$name = cleanup_text($name);
$location = cleanup_text($location);
$email = cleanup_text($email);
$url = cleanup_text($url);
$comments = cleanup_text($comments);

$errmsg = "";
if(empty($name)){
$errmsg .= "<li>you have to put in a name!\n";
}
// to check the format of the email address supplied by the user. an email
// address is required.
if (empty($email)|| !eregi("^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*",$email)){
$errmsg .="<li>$email doesn't look like a valid email address\n";
}
else {
$query = "select * from guestbook where email = '$email'";
$result = safe_query($query);
if(mysql_num_rows($result) > 0) {
$errmsg .="<li>this email has already sign this guestbook.\n";
}
}
// to check the format of the url supplied by the user
if(!empty($url) && !eregi("^http://[A-Za-z0-9\%\?\_\:\~\/\.-]+$",$url)) {
$errmsg .="<li>$url doesn't look like a valid URL\n";
}
if (empty($errmsg)){
$query = "insert into guestbook"
."(name,location,email,url,comments) values "
."('$name','$location','$email','$url','$comments')";
safe_query($query);

print "<h2>Thanks, $name!!</h2>\n";
}
else{


print <<<EOQ
<p>
<font color=red>
<b>
<ul>
$errmsg
</ul>
Please try again
</p>
EOQ;
}
return $errmsg;
}

// int select_entries ([int offset])
// Select a set of entries from the guestbook. The number of entries selected
// is determined by the value of the global variable limit. The offset
// argument determines where to start - the default value is zero, meaning
// the first record. Entries are retrieved in descending order of the date
// they were created. Return the mysql data set identifier for the rows
// retrieved.
function select_entries($offset=0) {
global $limit;

if(empty($offset)){ $offset = 0;}

$query = "select *
, date_format(created,'%e %M, %y %h:%i %p') as entry_date
from guestbook
order by created desc
limit $offset, $limit";

$result = safe_query($query);
return $result;

}

// void nav ([int offset [, string this_script]])
// Print out navigational links for moving through entries in the guestbook.
// The first argument indicates where to start - the default value is zero,
// meaning the first (most recent) record. The second argument is the name
// of the script to use in the link - if empty, the value of the predefined
// global variable PHP_SELF will be used - this will be the name of the file
// being displayed to the user (i.e., if bla.php includes display.php, which
// includes bottom.php, which calls this function, PHP_SELF will be "bla.php").

function nav ($offset=0,$this_script="")
{
global $limit;
global $PHP_SELF;

if (empty($this_script)) { $this_script = $PHP_SELF; }
if (empty($offset)) { $offset = 0; }

// get the total number of entries in the guest book -
// we need this to know if we can go forward from where we are
$result = safe_query("select count(*) from guestbook");
list($total_rows) = mysql_fetch_array($result);

print "<p>\n";
if ($offset > 0)
{
// if we're not on the first record, we can always go backwards
print "<a href=\"$this_script?offset=".($offset-$limit)."\"><<Previous Entries</a>   ";
}
if ($offset+$limit < $total_rows)
{
// offset + limit gives us the maximum record number
// that we could have displayed on this page. if it's
// less than the total number of entries, that means
// there are more entries to see, and we can go forward
print "<a href=\"$this_script?offset=".($offset+$limit)."\">Next Entries>></a>   ";
}
print "</p>\n";
}

?>

Et voici le code sign.php

<?php
include ("usefulfunc.php");
include "connection.php";
$page_title = "Sign My Guest Book!!";
include "start_pag.php";
if(!empty($_POST['test'])){
$errmsg = create_entry($_POST['name'], $_POST['location'], $_POST['email'] , $_POST['url'] , $_POST['comments']);
if (empty($errmsg))
{
include "end_pag.php";
exit;
}
}
?>

<form method=POST>
<table bgcolor="green">
<?php

print_input_fields("name","location","email","url");
?>
<tr>
<td valign=top align=rigth><b>Comments:</b></td>
<td valign=top align=left><textarea name=comments cols=40 rows=4></textarea></td>
</tr>

</table>
<input type=submit name=submit value="Sign!">
<input type=reset name=reset value="Start Over">
<input type='hidden' name='test' value="ok" />
</form>
<?php include "end_pag.php"; ?>

Merci d'avance pour votre aide.

7 réponses

jjsteing Messages postés 1670 Date d'inscription vendredi 11 mai 2007 Statut Contributeur Dernière intervention 21 mai 2012 181
9 août 2009 à 20:38
bonsoir :)

apres apres copier ton code dans un .php, chez moi pas de soucis... mis a part les includes qui n existe pas chez moi.. normal... y a un joli tableau vert qui s affiche...

donc je pense que ton soucis viens de "charset.php".. tu as du oublier de fermer une balise ou un " ou encore un ; ou ?>

mais bon, l erreur viens pas de ton fichier usefulfunc.php mais de charset.php
0
parvn Messages postés 49 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 7 mai 2012
9 août 2009 à 21:08
Merci, mais le probleme est que meme quand je l'enleve l'erreur persiste et toujours la a ligne 6 alors que logiquement en enlevant include("charset.php") il y'a une ligne de moins donc l'erreur devrais passe a la ligne 5 mais non toujours a la ligne 6 je ne comprend pas.
0
parvn Messages postés 49 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 7 mai 2012
9 août 2009 à 21:21
meme la connection de php a mysql ne functione plus.
0
jjsteing Messages postés 1670 Date d'inscription vendredi 11 mai 2007 Statut Contributeur Dernière intervention 21 mai 2012 181 > parvn Messages postés 49 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 7 mai 2012
9 août 2009 à 21:26
raison de plus pour réinstaller ;)

oubli pas de changer le mot de passe root dans mysql ;)
0
jjsteing Messages postés 1670 Date d'inscription vendredi 11 mai 2007 Statut Contributeur Dernière intervention 21 mai 2012 181
9 août 2009 à 21:12
reinstall ton easy php (la v3 est la derniere ;) )
0
lewis34 Messages postés 2557 Date d'inscription samedi 21 juillet 2007 Statut Membre Dernière intervention 30 mai 2015 352
9 août 2009 à 21:30
php est magique quand meme quand il y a une erreur il indique la raison faut juste savoir lire ^^
Parse error: syntax error, unexpected ';' 


donc tu a oublié un ;

comme tu utilise des includes il faut regarder dans ces includes ou il manque un ;
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
parvn Messages postés 49 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 7 mai 2012
9 août 2009 à 21:32
merci, j'ai trouve le probleme, il y'avait les fichers de l'ancien apache group dans mon disque c une fois que j'ai suprime ce dossier tout est rentre dans l'ordre.
Merci pour ton aide
0
jjsteing Messages postés 1670 Date d'inscription vendredi 11 mai 2007 Statut Contributeur Dernière intervention 21 mai 2012 181
9 août 2009 à 21:34
lol..

ben je t ais pas trop aider.. mais content que tu ais résolu ton probleme :)
0
lewis34 Messages postés 2557 Date d'inscription samedi 21 juillet 2007 Statut Membre Dernière intervention 30 mai 2015 352
9 août 2009 à 21:34
de rien pense seulement à mettre résolu dans ton post
0