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

PHP & Base de données Discussion :

Probleme Php site perso [Fait] [MySQL]


Sujet :

PHP & Base de données

  1. #21
    Membre émérite Avatar de macbook
    Inscrit en
    Février 2006
    Messages
    838
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 838
    Par défaut
    Comme tu utilises un require je peux être certain que l'inclusion du fichier de connexion s'est bien déroulée.

    Maintenant peut-être que tu ne donnes pas le bon identifiant de ressource à mysql_query().

    En l'ôtant de la requête :
    <?php
    $result&#160;
    =&#160;mysql_query($select)&#160;or&#160;die&#160;('Erreur&#160;:&#160;'.mysql_error()&#160;&#160;
    ?>

    Phpsyntaxcolor powered by decabodi.com
    Perso je ne passe jamais l'identifiant de connexion, j'ignore si c'est bien ou mal par contre...

  2. #22
    Rédacteur

    Avatar de Yogui
    Homme Profil pro
    Directeur technique
    Inscrit en
    Février 2004
    Messages
    13 721
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Yonne (Bourgogne)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Février 2004
    Messages : 13 721
    Par défaut
    @macbook : tant que tu n'as qu'une seule connexion MySQL (soit un seul serveur), ce qui est la quasi totalité des cas, c'est la bonne solution car il y a un souci de moins à régler (le paramètre de connexion est passé tout seul).

  3. #23
    Membre averti
    Inscrit en
    Mars 2004
    Messages
    49
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 49
    Par défaut
    yeahhhhhhhhhh ca marche enfin la page d'accueil !!!!!!!!!!!!!!!!!!!
    merchi merchi ca venait de là en faite j'aurais appris des trucs c cool !

    aarff maintenant pb sur la page admin mdrrrr
    http://mastercartman.free.fr/auth.php

    Je met le code de ma page admin :

    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
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    <?php require_once('Connections/basesiteperso.php'); ?>
    <?php require_once('Connections/basesiteperso.php'); ?>
     
    <?php
    if (!isset($_SESSION)) {
      session_start();
    }
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
     
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
      // For security, start by assuming the visitor is NOT authorized. 
      $isValid = False; 
     
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      if (!empty($UserName)) { 
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        $arrUsers = Explode(",", $strUsers); 
        $arrGroups = Explode(",", $strGroups); 
        if (in_array($UserName, $arrUsers)) { 
          $isValid = true; 
        } 
        // Or, you may restrict access to only certain users based on their username. 
        if (in_array($UserGroup, $arrGroups)) { 
          $isValid = true; 
        } 
        if (($strUsers == "") && true) { 
          $isValid = true; 
        } 
      } 
      return $isValid; 
    }
     
    $MM_restrictGoTo = "echec.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo); 
      exit;
    }
    ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
     
    $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET titre=%s, texte=%s, `date`=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['titre'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET titre=%s, texte=%s, `date`=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['titre'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
     
      $updateGoTo = "maj.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET titre=%s, texte=%s, `date`=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['titre'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
     
      $updateGoTo = "maj.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET date1=%s, titre1=%s, texte1=%s, date2=%s, titre2=%s, texte2=%s, date3=%s, titre3=%s, texte3=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['date1'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date2'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date3'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
     
      $updateGoTo = "maj.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET date1=%s, titre1=%s, texte1=%s, date2=%s, titre2=%s, texte2=%s, date3=%s, titre3=%s, texte3=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['date1'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date2'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date3'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
     
      $updateGoTo = "maj.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE news SET date1=%s, titre1=%s, texte1=%s, date2=%s, titre2=%s, texte2=%s, date3=%s, titre3=%s, texte3=%s WHERE id=%s",
                           GetSQLValueString($HTTP_POST_VARS['date1'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte1'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date2'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte2'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['date3'], "date"),
                           GetSQLValueString($HTTP_POST_VARS['titre3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['texte3'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['id'], "int"));
     
      mysql_select_db($database_basesiteperso, $basesiteperso);
      $Result1 = mysql_query($updateSQL, $basesiteperso) or die(mysql_error());
     
      $updateGoTo = "maj.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    mysql_select_db($database_basesiteperso, $basesiteperso);
    $query_Recordset1 = "SELECT * FROM news";
    $Recordset1 = mysql_query($query_Recordset1, $basesiteperso) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
     
    mysql_select_db($database_basesiteperso, $basesiteperso);
    $query_Recordset2 = "SELECT * FROM news";
    $Recordset2 = mysql_query($query_Recordset2, $basesiteperso) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);
    ?>
     
     
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Document sans titre</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
     
    <body>
    <form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
      <table width="100%" border="1">
        <!--DWLayoutTable-->
        <tr> 
          <td width="340">Mise &agrave; jour date :</td>
          <td width="414"><label> 
            <input name="date" type="text" id="date" value="<?php echo $row_Recordset1['date']; ?>">
            </label></td>
        </tr>
        <tr> 
          <td>Mise &agrave; jour titre :</td>
          <td><label> 
            <input name="titre" type="text" id="titre" value="<?php echo $row_Recordset1['titre']; ?>">
            </label></td>
        </tr>
        <tr> 
          <td>Mise &agrave; jour texte :</td>
          <td><label> 
            <textarea name="texte" id="texte"><?php echo $row_Recordset1['texte']; ?></textarea>
            </label></td>
        </tr>
        <tr> 
          <td height="2"></td>
          <td></td>
        </tr>
      </table>
      <br>
      <input name="id" type="hidden" id="id" value="<?php echo $row_Recordset1['id']; ?>">
      <br>
      <br>
      <input type="submit" name="Submit" value="Mise &agrave; jour">
      <input type="hidden" name="MM_update" value="form1">
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
     
    mysql_free_result($Recordset2);
    ?>

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Réponses: 5
    Dernier message: 04/07/2012, 16h01
  2. Creation d'une page php pour site perso
    Par mathoel dans le forum Langage
    Réponses: 75
    Dernier message: 29/07/2011, 15h34
  3. [ZF 1.7] Zend Framework ou php tout simple pour un site perso
    Par Dougli dans le forum Zend Framework
    Réponses: 7
    Dernier message: 23/03/2009, 14h43
  4. [Mutualisé] Heberger site perso musical (PHP/MySQL)
    Par sly60 dans le forum Hébergement
    Réponses: 4
    Dernier message: 04/02/2008, 13h05

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