IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

TPLN DB ERROR 2


Sujet :

Langage PHP

  1. #1
    Membre du Club
    Inscrit en
    Mai 2012
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Mai 2012
    Messages : 60
    Points : 48
    Points
    48
    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 :

    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.

  2. #2
    Membre expérimenté
    Homme Profil pro
    Développeur C++
    Inscrit en
    Avril 2012
    Messages
    771
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur C++
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2012
    Messages : 771
    Points : 1 631
    Points
    1 631
    Par défaut
    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.
    une réponse vous a permis d'avancer ?

  3. #3
    Membre du Club
    Inscrit en
    Mai 2012
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Mai 2012
    Messages : 60
    Points : 48
    Points
    48
    Par défaut erreur TPLN DB
    Non, Cette erreur arrive lorsque je veux modifier des données.

    index.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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>

  4. #4
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

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

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 418
    Points
    91 418
    Billets dans le blog
    20
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $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 !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  5. #5
    Membre du Club
    Inscrit en
    Mai 2012
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Mai 2012
    Messages : 60
    Points : 48
    Points
    48
    Par défaut
    Si! puisque la supression de données fonctionne.

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

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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'
     
    ?>

  6. #6
    Membre du Club
    Inscrit en
    Mai 2012
    Messages
    60
    Détails du profil
    Informations forums :
    Inscription : Mai 2012
    Messages : 60
    Points : 48
    Points
    48
    Par défaut erreur TPLN DB
    Le message d'erreur précis est le suivant :

    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'

    )

  7. #7
    Membre expérimenté
    Homme Profil pro
    Développeur C++
    Inscrit en
    Avril 2012
    Messages
    771
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur C++
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2012
    Messages : 771
    Points : 1 631
    Points
    1 631
    Par défaut
    Comme dit avant il n'y a pas de nom de table donc ta requête plante.
    une réponse vous a permis d'avancer ?

Discussions similaires

  1. ERROR: pg_atoi: zero-length string
    Par steelspirit92 dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 23/08/2003, 22h29
  2. [SQL Server] Error converting data type varchar...
    Par Sir Tengu dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 13/06/2003, 10h46
  3. [Kylix] Kylix c++ error
    Par pacpac dans le forum EDI
    Réponses: 2
    Dernier message: 10/06/2003, 16h27
  4. [CR] Print Engine error text
    Par afaraji dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 03/09/2002, 15h44
  5. [Kylix] Runtime error 230 avec INDY
    Par Anonymous dans le forum EDI
    Réponses: 2
    Dernier message: 23/03/2002, 11h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo