Précédent   Forum du club des développeurs et IT Pro > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 05/01/2013, 23h50   #1
idhmida
Invité régulier
 
Inscription : mai 2012
Messages : 32
Détails du profil
Informations forums :
Inscription : mai 2012
Messages : 32
Points : 6
Points : 6
Par défaut TPLN DB ERROR 2

Bonjour,

Pouvez-vous m'aider svp, j'ai un problème de code, lorsque j'insère dans la barre d'adresse localhost\projet il y a écrit :

Citation:
TPLN DB Error 2:
Problème de requete (You have an in error in your SQL,syntax; check the manual that corresponds to your MYSQL server version for the right syntax to use near "at line 1

SELECT COUNT(*) FROM

)
Merci de votre aide.
idhmida est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 07h06   #2
Exia93
Membre Expert
 
Homme
Étudiant
Inscription : avril 2012
Messages : 635
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : avril 2012
Messages : 635
Points : 1 118
Points : 1 118
bonjour,

l'erreur montre une erreur de syntaxe dans ta requête SQL,

ta requête est juste :
?

Si oui, il manque le nom de la table dans laquelle tu veut compter le nombre d’occurrence.
Exia93 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 14h42   #3
idhmida
Invité régulier
 
Inscription : mai 2012
Messages : 32
Détails du profil
Informations forums :
Inscription : mai 2012
Messages : 32
Points : 6
Points : 6
Par défaut erreur TPLN DB

Non, Cette erreur arrive lorsque je veux modifier des données.

index.php

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php 
// include TPLN (moteur de squelette ou de rendu html)
include('TPLN/TPLN.php');
include('db.inc');
 
$TPLN = new TPLN;
$TPLN->DbConnect('mysql',$server,$user,$pswd,$database);
 
if ($_GET['action']=='insert') { // Dans le cas d'une insertion
	$TPLN->Open('html/insert.html'); // Formulaire d'insertion
} else if (($_GET['action']=='update')) { // Dans le cas d'une modification
	$SQL = "SELECT * FROM $TABLE WHERE $identifiant='".$SQL .=$_GET[$identifiant]."'";
	$TPLN->Open('html/maj.html'); // Formulaire de modification
	$TPLN->ShowRecords($SQL,0);
} else {
	// Dans le cas d'une insertion
	if ($_POST && ($_POST['Go']=='Insertion') )
		$TPLN->DBInsert($table, $_POST, array('Go'));
 
	// Dans le cas d'une modification
	if ($_POST && ($_POST['Go']=='Valider') )
		$TPLN->DBUpdate($table, $_POST, "$identifiant=".$_POST[$identifiant], array('Go'));
 
	// Dans le cas d'une suppression
	if (isset($_GET['id']))	
		$TPLN->DBDelete($table, "$identifiant={$_GET[$identifiant]}");
 
	// Ensuite on affiche tout
	$TPLN->Open('html/webmaster.html');
	$TPLN->SetNavColor('#FFFFFF','#FFFFC0'); // changement de couleurs
 
	$TPLN->ShowRecordsOrderBy(array($identifiant)); // filtre par id et nom
	$TPLN->ShowRecords("SELECT * FROM $table", 10); // seulement 10 par page
}
 
$TPLN->DBClose();
$TPLN->Write();
 
?>
 
 
maj.html 
 
<!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>Mon projet - édition</title>
</head>
<body>
 
 
 
		<IMG 
			SRC ="../images/banniere.jpg"
			width ="760"
			height ="190"
			alt="banniere paris">	
		<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
		<script type="text/javascript" src="../js/overlib.js"></script><!-- overLIB (c) Erik Bosrup -->
 
		<div id="menu">
 
		<div class="element_menu">
		<h3><b>MENU</b></h3>
		<ul>
		<li style="color:transparent;">&nbsp;</li>
		<li><a href="../index.php">Accueil</a></li><br>
        <li><a href="situation.html">Le logement à Paris aujourd'hui </a></li>
        <li style="color:transparent;">&nbsp;</li>
        <li><a href="loyer.html">De quoi le loyer dépend-t-il?</a></li>
        <li style="color:transparent;">&nbsp;</li>
        <li><a href="evolution.html">Evolution du logement à Paris</a></li>
        <li style="color:transparent;">&nbsp;</li>
		<li><a href="coin.html">Coins sympas à Paris</a></li>
        <li style="color:transparent;">&nbsp;</li>
		<li><a href="Contact.html">Nous contacter</a></li>
        </ul>  
		</div>
 
		</div>
<FORM id="form" name="form" action="{$_SERVER['PHP_SELF']}" method="post">  
<bloc::data>
<bloc::loop> 
Votre nom : <INPUT TYPE=text NAME="nom" value="{Votre nom}"><br><br>
Votre prenom : <input type="text" name="prenom" value="{Votre prenom}" size="30"><br><br>
Votre âge : <input type="text" name="age" value="{Votre âge}" size="50"><br><br>
Dans quel arrondissement souhaitez-vous vivre ?: <input type="text" name="arrondissement" value="{Dans quel arrondissement souhaitez-vous vivre ?}" ><br><br>
Type de logement: <input type="text" name="type" value="{Type de logement}" size="20"><br><br>
Loyer : <input type="text" name="loyer"  value="{Loyer}" size="50"><br><br>
<input type="hidden" name="id" value="{id}"><br><br>
<input type="submit" name="Go" value="Valider"> <br><br>
</bloc::loop>
<bloc::norecord>Erreur</bloc::norecord>
</bloc::data>
<A
			href="../index.php"
			title="Aller sur index">Retour Accueil</A>
<br>
</FORM>
 
</body>
</html>
idhmida est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 15h12   #4
Bovino
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 18 547
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 42
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2008
Messages : 18 547
Points : 66 425
Points : 66 425
Code :
$SQL = "SELECT * FROM $TABLE WHERE $identifiant='".$SQL .=$_GET[$identifiant]."'";
Ca veut rien dire cette ligne...
__________________
Pas de question technique par MP !
Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, contactez-moi !
Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
Mon livre sur jQuery
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 15h16   #5
idhmida
Invité régulier
 
Inscription : mai 2012
Messages : 32
Détails du profil
Informations forums :
Inscription : mai 2012
Messages : 32
Points : 6
Points : 6
Si! puisque la supression de données fonctionne.

les variables php sont rattachés au fichier db.inc:

Code :
1
2
3
4
5
6
7
8
9
10
11
<?
$server = 'localhost';
$user='root';
$pswd='';
$database='mabase'; //changer nom de base, pas obliger
 
$table = 'utilisateurs'; // changer nom de table
$identifiant='id'; // identifiant unique
$web_path='http://localhost/projet/TPLN'
 
?>
idhmida est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 15h30   #6
idhmida
Invité régulier
 
Inscription : mai 2012
Messages : 32
Détails du profil
Informations forums :
Inscription : mai 2012
Messages : 32
Points : 6
Points : 6
Par défaut erreur TPLN DB

Le message d'erreur précis est le suivant :

Citation:
Problème de requete (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='2'' at line 1

SELECT COUNT(*)FROM WHERE id='2'

)
idhmida est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 22h19   #7
Exia93
Membre Expert
 
Homme
Étudiant
Inscription : avril 2012
Messages : 635
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : avril 2012
Messages : 635
Points : 1 118
Points : 1 118
Comme dit avant il n'y a pas de nom de table donc ta requête plante.
Exia93 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 02h54.


 
 
 
 
Partenaires

Hébergement Web