Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 11/01/2012, 17h52   #1
Nouveau Membre du Club
 
Homme
Étudiant
Inscription : mars 2009
Messages : 76
Détails du profil
Informations personnelles :
Sexe : Homme

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mars 2009
Messages : 76
Points : 25
Points : 25
Par défaut Problème de guillemet (Parse error: syntax error, unexpected T_VARIABLE)

Bonjour
Je suis débutant dans le domaine.
j'ai ce message d'erreur qui s'affiche lorsque j’exécute ma page pour faire un test
Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\ASSURANCE\formtest.php on line 38
Depuis hier je cherche mais je ne trouve pas la solution, j'espère pouvoir trouver de l'aide ici.
Voici mon code
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 
<body>
  <form method="post" action="formtest.php">
  <fieldset>
   <p>
       <label for="nom">Votre situation g&eacute;ographique</label>
       <input type="text" name="situg" id="situg" />
   </p> 
   <p> 
       Votre formule:
 
           <input type="radio" name="formule" value="eco" id="eco" /> <label for="eco">Economique</label>
           <input type="radio" name="formule" value="moyenne" id="moyenne" /> <label for="moyenne">Moyenne</label>
           <input type="radio" name="formule" value="prestige" id="prestige" /> <label for="prestige">Prestige</label>
   </p>
 
   <input type ="submit" value ="Afficher"/>
   </fieldset>
</form>
 
<?php
   if(isset($_POST["Afficher"])) // vérifie le clic sur le btn
    {
	  $option = $_POST['formule'];
      $geositu = $_POST['situg'];
	  if(isset($option) AND isset($geositu))
	  {
	    try
          {
        	$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
	        $bdd = new PDO('mysql:host=localhost;dbname=sogemad', 'root', '',$pdo_options);
	        $reponse = $bdd->query('SELECT * FROM prestataire WHERE sitegeo = '$geositu'AND optionf ='$option'');
	   ?>
	     <TABLE BORBER=1>
			 <TR>
			  <TH>PRESTATAIRE</TH><TH>LOCALISATION</TH><TH>VILLE/COMMUNE</TH><TH>TELEPHONE</TH><TH>FORMULE</TH><TH>CATEGORIE</TH>
			 </TR>
	   <?php 
 
			 while ($donnees = $reponse->fetch())
			  {  
		?>
		      <TR>
				<TD><?php echo "$donnees['nompresta']"?></TD><TD><?php echo "$donnees['situgeo']"?></TD>
				<TD><?php echo "$donnees['commune']"?></TD><TD><?php echo "$donnees['tel']"?></TD>
				<TD><?php echo "$donnees['optionf']"?></TD><TD><?php echo "$donnees['categorie']"?></TD>
			 </TR>
		      <?php 
	            }
              ?>
        </TABLE>
		<?php 
	  $reponse->closeCursor();
         }
      catch (Exception $e)
 {
	die('Erreur : ' $e->getMessage());
 }
?>
 
</body>
</html>
Merci pour votre aide
babacan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2012, 17h57   #2
Membre expérimenté
 
Avatar de amoiraud
 
Homme Adrien
Développeur Web
Inscription : octobre 2006
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Adrien
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2006
Messages : 412
Points : 537
Points : 537
Envoyer un message via MSN à amoiraud
Salut,

Le problème est à la ligne 38 (fin de quote et variable sans concaténation), essaye de la remplacer par :

Code :
1
2
 
$reponse = $bdd->query('SELECT * FROM prestataire WHERE sitegeo = ' . $geositu . ' AND optionf = ' . $option);

EDIT :

Et si tes champs sitegeo et/ou optionf sont des chaines, ajouter des doubles quotes :

Code :
1
2
 
$reponse = $bdd->query('SELECT * FROM prestataire WHERE sitegeo = "' . $geositu . '" AND optionf = "' . $option . '"');
amoiraud est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2012, 10h42   #3
Nouveau Membre du Club
 
Homme
Étudiant
Inscription : mars 2009
Messages : 76
Détails du profil
Informations personnelles :
Sexe : Homme

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mars 2009
Messages : 76
Points : 25
Points : 25
Merci amoiraud pour ton aide j'ai pu résoudre ton problème
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 
<body>
  <form method="post" action="formtest.php">
  <fieldset>
   <p>
       <label for="nom">Votre situation g&eacute;ographique</label>
       <input type="text" name="situg" id="situg" />
   </p> 
   <p> 
       Votre formule:
 
           <input type="radio" name="formule" value="eco" id="eco" /> <label for="eco">Economique</label>
           <input type="radio" name="formule" value="moyenne" id="moyenne" /> <label for="moyenne">Moyenne</label>
           <input type="radio" name="formule" value="prestige" id="prestige" /> <label for="prestige">Prestige</label>
   </p>
 
   <input type ="submit" value ="Afficher"/>
   </fieldset>
</form>	 
 
<?php
	  if(isset($_POST['situg']) AND isset($_POST['formule']))
	  {
	    	  $option = $_POST['formule'];
              $geositu = $_POST['situg'];
 
	    try
          {
        	$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
	        $bdd = new PDO('mysql:host=localhost;dbname=sogemad', 'root', '',$pdo_options);
 
             $reponse = $bdd->query('SELECT * FROM prestataire WHERE commune = "' . $geositu . '" AND optionf = "' . $option . '"');			 
?>
	     <TABLE BORBER=1>
			 <TR>
			  <TH>PRESTATAIRE</TH><TH>LOCALISATION</TH><TH>VILLE/COMMUNE</TH><TH>TELEPHONE</TH><TH>FORMULE</TH><TH>CATEGORIE</TH>
			 </TR>
	   <?php 
	   	 while ($donnees = $reponse->fetch())
		  {  
		?>
		      <TR>
				<TD> <?php echo "$donnees[nompresta]" ?> </TD>
				<TD> <?php echo "$donnees[sitegeo]" ?> </TD>
				<TD> <?php echo "$donnees[commune]" ?> </TD>
				<TD> <?php echo "$donnees[tel]" ?> </TD>
				<TD> <?php echo "$donnees[optionf]" ?> </TD>
				<TD> <?php echo "$donnees[categorie]" ?> </TD>
			 </TR>
		 <?php 
	        }
         ?>
        </TABLE>
		<?php 
	  $reponse->closeCursor();
         }
      catch (Exception $e)
		 {
			die('Erreur : ' .$e->getMessage());
		 }
      }
	// }
?>
 
</body>
</html>
babacan est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h02.


 
 
 
 
Partenaires

Hébergement Web