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 :

Pb d'insertion datapicker [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb d'insertion datapicker
    Bonjour,

    J'ai realise un formulaire en Php dans lequel un champ est une date d'ou ma volonte d'inserer un datapicker mais lors de mes test lors de clique sur le bouton d'envoi la base de données est incrementée mais le la date reste 0000-00-00 alors que les autres champs sont correctement remplis.

    Voici mon code :
    <?php require_once('Connections/cnxTestDate1.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ajout-vacations")) {
    $insertSQL = sprintf("INSERT INTO vacation (num_vacation, nom_vac, num_iade, num_bloc, dat) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['numero_vac'], "int"),
    GetSQLValueString($_POST['libelle_vac'], "text"),
    GetSQLValueString($_POST['num_iade'], "int"),
    GetSQLValueString($_POST['num_bloc'], "int"),
    GetSQLValueString($_POST['dat'], "date"));

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $Result1 = mysql_query($insertSQL, $cnxTestDate1) or die(mysql_error());
    }

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $query_rsIade = "SELECT * FROM iade";
    $rsIade = mysql_query($query_rsIade, $cnxTestDate1) or die(mysql_error());
    $row_rsIade = mysql_fetch_assoc($rsIade);
    $totalRows_rsIade = mysql_num_rows($rsIade);

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $query_rsbloc = "SELECT * FROM bloc";
    $rsbloc = mysql_query($query_rsbloc, $cnxTestDate1) or die(mysql_error());
    $row_rsbloc = mysql_fetch_assoc($rsbloc);
    $totalRows_rsbloc = mysql_num_rows($rsbloc);
    ?>
    <!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=utf-8" />
    <title>Document sans titre</title>

    <link type="text/css" href="css/style.css" rel="stylesheet" />
    <link type="text/css" href="css/cupertino/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" src="js/ui.datepicker-fr.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {
    $("#datepicker").datepicker();
    });
    </script>

    <style type="text/css">
    #ui-datepicker-div{ font-size: 80%; }
    </style>

    </head>

    <body>
    <p>&nbsp;</p>
    <form id="ajout-vacations" name="ajout-vacations" method="POST" action="<?php echo $editFormAction; ?>">
    <p>
    <label for="numero_vac">Numero vacation :</label>
    <input type="text" name="numero_vac" id="numero_vac" accesskey="n" tabindex="1" />
    </p>
    <p>
    <label for="libelle_vac">Nom vacation :</label>
    <input type="text" name="libelle_vac" id="libelle_vac" accesskey="l" tabindex="2" />
    </p>
    <p>
    <label for="num_iade">Numero IADE :</label>
    <select name="num_iade" id="num_iade" accesskey="i" tabindex="3">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rsIade['num_iade']?>"><?php echo $row_rsIade['num_iade']?></option>
    <?php
    } while ($row_rsIade = mysql_fetch_assoc($rsIade));
    $rows = mysql_num_rows($rsIade);
    if($rows > 0) {
    mysql_data_seek($rsIade, 0);
    $row_rsIade = mysql_fetch_assoc($rsIade);
    }
    ?>
    </select>
    </p>
    <p>
    <label for="num_bloc">Numero Bloc :</label>
    <select name="num_bloc" id="num_bloc" accesskey="b" tabindex="4">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rsbloc['num_bloc']?>"><?php echo $row_rsbloc['num_bloc']?></option>
    <?php
    } while ($row_rsbloc = mysql_fetch_assoc($rsbloc));
    $rows = mysql_num_rows($rsbloc);
    if($rows > 0) {
    mysql_data_seek($rsbloc, 0);
    $row_rsbloc = mysql_fetch_assoc($rsbloc);
    }
    ?>
    </select>
    </p>
    <p>
    <label for="dat">Date :</label>

    <input type="text" id="datepicker" name="datepicker" />
    </p>
    <p>&nbsp;</p>
    <p>
    <input type="submit" name="envoi" id="envoi" value="Ajout d'une vacation" accesskey="e" tabindex="6" />
    </p>
    <p>&nbsp;</p>
    <input type="hidden" name="MM_insert" value="ajout-vacations" />
    </form>
    <p>&nbsp;</p>
    </body>
    </html>
    <?php
    mysql_free_result($rsIade);

    mysql_free_result($rsbloc);
    ?>
    La copie du fichier pour creer la base
    -- phpMyAdmin SQL Dump
    -- version 3.3.9
    -- http://www.phpmyadmin.net
    --
    -- Serveur: localhost
    -- Généré le : Dim 06 Novembre 2011 à 21:09
    -- Version du serveur: 5.5.8
    -- Version de PHP: 5.3.1

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;

    --
    -- Base de données: `test_date_1`
    --
    CREATE DATABASE `test_date_1` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    USE `test_date_1`;

    -- --------------------------------------------------------

    --
    -- Structure de la table `bloc`
    --

    DROP TABLE IF EXISTS `bloc`;
    CREATE TABLE IF NOT EXISTS `bloc` (
    `num_bloc` int(4) NOT NULL,
    `nom_bloc` varchar(255) COLLATE utf8_unicode_ci NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    --
    -- Contenu de la table `bloc`
    --

    INSERT INTO `bloc` (`num_bloc`, `nom_bloc`) VALUES
    (1, 'BMC 11'),
    (2, 'BMC 12'),
    (3, 'BMC 13'),
    (4, 'BMC 14'),
    (5, 'BMC 15'),
    (6, 'BMC 16'),
    (7, 'BMC 17'),
    (8, 'BMC 18'),
    (9, 'BMC 19'),
    (10, 'BMC 20');

    -- --------------------------------------------------------

    --
    -- Structure de la table `iade`
    --

    DROP TABLE IF EXISTS `iade`;
    CREATE TABLE IF NOT EXISTS `iade` (
    `num_iade` int(4) NOT NULL,
    `nom_iade` varchar(255) COLLATE utf8_unicode_ci NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    --
    -- Contenu de la table `iade`
    --

    INSERT INTO `iade` (`num_iade`, `nom_iade`) VALUES
    (1, 'AMIOT'),
    (2, 'BISSON'),
    (3, 'BOUTET'),
    (4, 'CANU'),
    (5, 'CARON'),
    (6, 'COURDY'),
    (7, 'DUMOND'),
    (8, 'DUROT'),
    (9, 'FOUQUET'),
    (10, 'GAYEZ');

    -- --------------------------------------------------------

    --
    -- Structure de la table `vacation`
    --

    DROP TABLE IF EXISTS `vacation`;
    CREATE TABLE IF NOT EXISTS `vacation` (
    `num_vacation` int(4) NOT NULL,
    `nom_vac` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `num_iade` int(4) NOT NULL,
    `num_bloc` int(4) NOT NULL,
    `dat` date DEFAULT '0000-00-00'
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    --
    -- Contenu de la table `vacation`
    --

    INSERT INTO `vacation` (`num_vacation`, `nom_vac`, `num_iade`, `num_bloc`, `dat`) VALUES
    (1, 'vac1', 1, 2, '2011-11-01'),
    (2, 'vac2', 1, 2, '2011-11-02');
    La copie du fichier de connexion
    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_cnxTestDate1 = "localhost";
    $database_cnxTestDate1 = "test_date_1";
    $username_cnxTestDate1 = "raphael";
    $password_cnxTestDate1 = "azer1234";
    $cnxTestDate1 = mysql_pconnect($hostname_cnxTestDate1, $username_cnxTestDate1, $password_cnxTestDate1) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    Auriez vous une idée de l'erreur que j'ai faite ? Un conseil ? une idée ? SVP Merci

    Raphael

  2. #2
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut Probleme de format date
    Bonjour,
    Je crois que le probleme vient du format de la date
    Cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb datapicker
    Bonjour,

    Merci pour cette reponse mais est ce que vous pourriez etes plus precis ? SVP Merci

    Raphael

  4. #4
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re:
    Cette ligne me semble suspecte :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    GetSQLValueString($_POST['dat'], "date"));
    j'ai parcouru ton code source, mais je n'ai pas trouvé un champ qui possede l'attribut nom 'dat', ne serait ce pas "datepicker" ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input type="text" id="datepicker" name="datepicker" />
    Si c'est le cas faut remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    GetSQLValueString($_POST['datepicker'], "date"));
    Cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb datapicker
    Salut,

    merci

    grace a ta reponse, je vois apparaitre le Datapicker quand je clique sur le champs mais quand je valide (apres avoir selectionne une date, je la vois apparaitre dans le champs et le datapicker disparait) la base s'increment d'un nouvel enregistrement mais la date enregistree reste 0000-00-00.

    Aurais tu une nouvelle brillante idee ?

    SVP Merci

    Raphael

  6. #6
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re:
    Je ne sais pas si ça va fonctionner, mais faut verifier le format de la date sur ton champ de saisie de la date "2012-01-28", Ensuite utiliser la fonction strtotime("2012-01-28") avant l'insertion dans la base

    Faut mettre le format de la date soi en ISO c'est a dire yyyy-mm-dd, une fois que t'as ta date a partir de ton datepicker faut la découper, l'assembler et la transformer au format yyyy-mm-dd (exemple 2012-01-28), pour ensuite l'inserer dans la base de donnée

    Essaye ça avec le fragmeent de code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ajout-vacations")) {
     $insertSQL = sprintf("INSERT INTO vacation (num_vacation, nom_vac, num_iade, num_bloc, dat) VALUES (%s, %s, %s, %s, NOW())",
     GetSQLValueString($_POST['numero_vac'], "int"),
     GetSQLValueString($_POST['libelle_vac'], "text"),
     GetSQLValueString($_POST['num_iade'], "int"),
     GetSQLValueString($_POST['num_bloc'], "int")
     //GetSQLValueString($_POST['dat'], "date"))
    If you type Google into Google, you Can break the internet" - The IT Crowd

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Probleme de code (suite)
    Salut,

    Merci de l'aide.

    Question du debutant que je suis où placer ton fragment de code ?

    SVP Merci

    Raphael

  8. #8
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re:
    J'ai testé le code chez moi il fonctionne, une petite question avant de cliquer sur le bouton "ajouter une vacation" tu peux me donner ce que le champ date contient ?
    If you type Google into Google, you Can break the internet" - The IT Crowd

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb Datepicker -suite
    il contient 28-01-2012

    cela t'aide ?

    Raphael

  10. #10
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re :
    Eureka !! La on voit d'ou provient le probleme le format d'insertion n'est pas correcte le format de la date est
    28-01-2012 = jj-mm-aaaa

    Mais avant l'insertion dans la base de donnée faut qu'il soit de la forme
    aaaa-mm-jj c'est a dire 2012-01-28.

    Remplace 28-01-2012 par 2012-01-28 dans le champ de saisie pour tester si ça fontionne cordialement
    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
    <?php require_once('Connections/cnxTestDate1.php'); ?>
     <?php
     if (!function_exists("GetSQLValueString")) {
     function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
     {
     if (PHP_VERSION < 6) {
     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
    
     $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
     if (isset($_SERVER['QUERY_STRING'])) {
     $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
     }
     $date = implode('-', array_reverse( explode('-',$_POST['datepicker']) ) ) ;
     if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ajout-vacations")) {
     $insertSQL = sprintf("INSERT INTO vacation (num_vacation, nom_vac, num_iade, num_bloc, dat) VALUES (%s, %s, %s, %s, %s)",
     GetSQLValueString($_POST['numero_vac'], "int"),
     GetSQLValueString($_POST['libelle_vac'], "text"),
     GetSQLValueString($_POST['num_iade'], "int"),
     GetSQLValueString($_POST['num_bloc'], "int"),
     GetSQLValueString($date, "date"));
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $Result1 = mysql_query($insertSQL, $cnxTestDate1) or die(mysql_error());
     }
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $query_rsIade = "SELECT * FROM iade";
     $rsIade = mysql_query($query_rsIade, $cnxTestDate1) or die(mysql_error());
     $row_rsIade = mysql_fetch_assoc($rsIade);
     $totalRows_rsIade = mysql_num_rows($rsIade);
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $query_rsbloc = "SELECT * FROM bloc";
     $rsbloc = mysql_query($query_rsbloc, $cnxTestDate1) or die(mysql_error());
     $row_rsbloc = mysql_fetch_assoc($rsbloc);
     $totalRows_rsbloc = mysql_num_rows($rsbloc);
     ?>
     <!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=utf-8" />
     <title>Document sans titre</title>
    
     <link type="text/css" href="css/style.css" rel="stylesheet" />
     <link type="text/css" href="css/cupertino/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
     <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
     <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
     <script type="text/javascript" src="js/ui.datepicker-fr.js"></script>
    
     <script type="text/javascript">
     $(document).ready(function() {
     $("#datepicker").datepicker();
     }); 
     </script> 
    
     <style type="text/css">
     #ui-datepicker-div{ font-size: 80%; }
     </style>
    
     </head>
    
     <body>
     <p>&nbsp;</p>
     <form id="ajout-vacations" name="ajout-vacations" method="POST" action="<?php echo $editFormAction; ?>">
     <p>
     <label for="numero_vac">Numero vacation :</label>
     <input type="text" name="numero_vac" id="numero_vac" accesskey="n" tabindex="1" />
     </p>
     <p>
     <label for="libelle_vac">Nom vacation :</label>
     <input type="text" name="libelle_vac" id="libelle_vac" accesskey="l" tabindex="2" />
     </p>
     <p>
     <label for="num_iade">Numero IADE :</label>
     <select name="num_iade" id="num_iade" accesskey="i" tabindex="3">
     <?php
     do { 
     ?>
     <option value="<?php echo $row_rsIade['num_iade']?>"><?php echo $row_rsIade['num_iade']?></option>
     <?php
     } while ($row_rsIade = mysql_fetch_assoc($rsIade));
     $rows = mysql_num_rows($rsIade);
     if($rows > 0) {
     mysql_data_seek($rsIade, 0);
     $row_rsIade = mysql_fetch_assoc($rsIade);
     }
     ?>
     </select>
     </p>
     <p>
     <label for="num_bloc">Numero Bloc :</label>
     <select name="num_bloc" id="num_bloc" accesskey="b" tabindex="4">
     <?php
     do { 
     ?>
     <option value="<?php echo $row_rsbloc['num_bloc']?>"><?php echo $row_rsbloc['num_bloc']?></option>
     <?php
     } while ($row_rsbloc = mysql_fetch_assoc($rsbloc));
     $rows = mysql_num_rows($rsbloc);
     if($rows > 0) {
     mysql_data_seek($rsbloc, 0);
     $row_rsbloc = mysql_fetch_assoc($rsbloc);
     }
     ?>
     </select>
     </p>
     <p>
     <label for="dat">Date :</label>
    
     <input type="text" id="datepicker" name="datepicker" />
     </p>
     <p>&nbsp;</p>
     <p>
     <input type="submit" name="envoi" id="envoi" value="Ajout d'une vacation" accesskey="e" tabindex="6" />
     </p>
     <p>&nbsp;</p>
     <input type="hidden" name="MM_insert" value="ajout-vacations" />
     </form>
     <p>&nbsp;</p>
     </body>
     </html>
     <?php
     mysql_free_result($rsIade);
    
     mysql_free_result($rsbloc);
     ?>
    Normalement le code ci dessus devrait fonctionner grace a la ligne que j'ai rajouté en vert qui transforme le format date jj-mm-aaaa en aaaa-mm-jj
    If you type Google into Google, you Can break the internet" - The IT Crowd

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb Datepicker -suite
    Cela fonctionne !!!

    Donc il me faut inverser le format : je sais pas faire encore une nouvelle interrogation pour moi.

    La base de donnees est codee en
    utf8-unicode-ci

    est cela la cause ??

    Y a t il un remede "docteur" ?

    SVP Merci

    Raphael

  12. #12
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re:
    Non ça n'a rien avoir avec l'encodage UTF-8 ça c'est une autre histoire ton encodage est presque parfait c'est juste un probleme de date, avant d'inserer une date dans la base il faut qu'elle soit du format aaaa-mm-jj et rien d'autre ne pourrait fonctionner donc pour se faire, faut inverser la chaine de caractères
    Exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    $date ="12-01-2012";
    $date = implode('-', array_reverse( explode('-',"12-01-2012" ) ) ;
    // La on peut inserer dans la base de donnée
    Mais bon on peut utiliser d'autres méthodes
    Cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

  13. #13
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Re :
    Eureka !! La on voit d'ou provient le probleme le format d'insertion n'est pas correcte le format de la date est
    28-01-2012 = jj-mm-aaaa

    Mais avant l'insertion dans la base de donnée faut qu'il soit de la forme
    aaaa-mm-jj c'est a dire 2012-01-28.

    Remplace 28-01-2012 par 2012-01-28 dans le champ de saisie pour tester si ça fontionne cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

  14. #14
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb Datepicker -suite
    Je place ton extrait de code

    $date ="12-01-2012";
    $date = implode('-', array_reverse( explode('-',"12-01-2012" ) ) ;
    // La on peut inserer dans la base de donnée
    Où dans mon code source ?SVP Merci

    Mon code actuel :

    <?php require_once('Connections/cnxTestDate1.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ajout-vacations")) {
    $insertSQL = sprintf("INSERT INTO vacation (num_vacation, nom_vac, num_iade, num_bloc, dat) VALUES (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['numero_vac'], "int"),
    GetSQLValueString($_POST['libelle_vac'], "text"),
    GetSQLValueString($_POST['num_iade'], "int"),
    GetSQLValueString($_POST['num_bloc'], "int"),
    GetSQLValueString($_POST['datepicker'], "date"));

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $Result1 = mysql_query($insertSQL, $cnxTestDate1) or die(mysql_error());
    }

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $query_rsIade = "SELECT * FROM iade";
    $rsIade = mysql_query($query_rsIade, $cnxTestDate1) or die(mysql_error());
    $row_rsIade = mysql_fetch_assoc($rsIade);
    $totalRows_rsIade = mysql_num_rows($rsIade);

    mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
    $query_rsbloc = "SELECT * FROM bloc";
    $rsbloc = mysql_query($query_rsbloc, $cnxTestDate1) or die(mysql_error());
    $row_rsbloc = mysql_fetch_assoc($rsbloc);
    $totalRows_rsbloc = mysql_num_rows($rsbloc);
    ?>
    <!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=utf-8" />
    <title>Document sans titre</title>

    <link type="text/css" href="css/style.css" rel="stylesheet" />
    <link type="text/css" href="css/cupertino/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" src="js/ui.datepicker-fr.js"></script>

    <script type="text/javascript">
    $(document).ready(function() {
    $("#datepicker").datepicker();
    });
    </script>

    <style type="text/css">
    #ui-datepicker-div{ font-size: 80%; }
    </style>

    </head>

    <body>
    <p>&nbsp;</p>
    <form id="ajout-vacations" name="ajout-vacations" method="POST" action="<?php echo $editFormAction; ?>">
    <p>
    <label for="numero_vac">Numero vacation :</label>
    <input type="text" name="numero_vac" id="numero_vac" accesskey="n" tabindex="1" />
    </p>
    <p>
    <label for="libelle_vac">Nom vacation :</label>
    <input type="text" name="libelle_vac" id="libelle_vac" accesskey="l" tabindex="2" />
    </p>
    <p>
    <label for="num_iade">Numero IADE :</label>
    <select name="num_iade" id="num_iade" accesskey="i" tabindex="3">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rsIade['num_iade']?>"><?php echo $row_rsIade['num_iade']?></option>
    <?php
    } while ($row_rsIade = mysql_fetch_assoc($rsIade));
    $rows = mysql_num_rows($rsIade);
    if($rows > 0) {
    mysql_data_seek($rsIade, 0);
    $row_rsIade = mysql_fetch_assoc($rsIade);
    }
    ?>
    </select>
    </p>
    <p>
    <label for="num_bloc">Numero Bloc :</label>
    <select name="num_bloc" id="num_bloc" accesskey="b" tabindex="4">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rsbloc['num_bloc']?>"><?php echo $row_rsbloc['num_bloc']?></option>
    <?php
    } while ($row_rsbloc = mysql_fetch_assoc($rsbloc));
    $rows = mysql_num_rows($rsbloc);
    if($rows > 0) {
    mysql_data_seek($rsbloc, 0);
    $row_rsbloc = mysql_fetch_assoc($rsbloc);
    }
    ?>
    </select>
    </p>
    <p>
    <label for="dat">Date :</label>

    <input type="text" id="datepicker" name="datepicker" />
    </p>
    <p>&nbsp;</p>
    <p>
    <input type="submit" name="envoi" id="envoi" value="Ajout d'une vacation" accesskey="e" tabindex="6" />
    </p>
    <p>&nbsp;</p>
    <input type="hidden" name="MM_insert" value="ajout-vacations" />
    </form>
    <p>&nbsp;</p>
    </body>
    </html>
    <?php
    mysql_free_result($rsIade);

    mysql_free_result($rsbloc);
    ?>
    SVP Merci

    Raphael

  15. #15
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    Bon, je Les modification sont en vert
    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
    <?php require_once('Connections/cnxTestDate1.php'); ?>
     <?php
     if (!function_exists("GetSQLValueString")) {
     function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
     {
     if (PHP_VERSION < 6) {
     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
    
     $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
     if (isset($_SERVER['QUERY_STRING'])) {
     $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
     }
     $date = implode('-', array_reverse( explode('-',$_POST['datepicker']) ) ) ;
     if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ajout-vacations")) {
     $insertSQL = sprintf("INSERT INTO vacation (num_vacation, nom_vac, num_iade, num_bloc, dat) VALUES (%s, %s, %s, %s, %s)",
     GetSQLValueString($_POST['numero_vac'], "int"),
     GetSQLValueString($_POST['libelle_vac'], "text"),
     GetSQLValueString($_POST['num_iade'], "int"),
     GetSQLValueString($_POST['num_bloc'], "int"),
     GetSQLValueString($date, "date"));
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $Result1 = mysql_query($insertSQL, $cnxTestDate1) or die(mysql_error());
     }
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $query_rsIade = "SELECT * FROM iade";
     $rsIade = mysql_query($query_rsIade, $cnxTestDate1) or die(mysql_error());
     $row_rsIade = mysql_fetch_assoc($rsIade);
     $totalRows_rsIade = mysql_num_rows($rsIade);
    
     mysql_select_db($database_cnxTestDate1, $cnxTestDate1);
     $query_rsbloc = "SELECT * FROM bloc";
     $rsbloc = mysql_query($query_rsbloc, $cnxTestDate1) or die(mysql_error());
     $row_rsbloc = mysql_fetch_assoc($rsbloc);
     $totalRows_rsbloc = mysql_num_rows($rsbloc);
     ?>
     <!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=utf-8" />
     <title>Document sans titre</title>
    
     <link type="text/css" href="css/style.css" rel="stylesheet" />
     <link type="text/css" href="css/cupertino/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
     <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
     <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
     <script type="text/javascript" src="js/ui.datepicker-fr.js"></script>
    
     <script type="text/javascript">
     $(document).ready(function() {
     $("#datepicker").datepicker();
     }); 
     </script> 
    
     <style type="text/css">
     #ui-datepicker-div{ font-size: 80%; }
     </style>
    
     </head>
    
     <body>
     <p>&nbsp;</p>
     <form id="ajout-vacations" name="ajout-vacations" method="POST" action="<?php echo $editFormAction; ?>">
     <p>
     <label for="numero_vac">Numero vacation :</label>
     <input type="text" name="numero_vac" id="numero_vac" accesskey="n" tabindex="1" />
     </p>
     <p>
     <label for="libelle_vac">Nom vacation :</label>
     <input type="text" name="libelle_vac" id="libelle_vac" accesskey="l" tabindex="2" />
     </p>
     <p>
     <label for="num_iade">Numero IADE :</label>
     <select name="num_iade" id="num_iade" accesskey="i" tabindex="3">
     <?php
     do { 
     ?>
     <option value="<?php echo $row_rsIade['num_iade']?>"><?php echo $row_rsIade['num_iade']?></option>
     <?php
     } while ($row_rsIade = mysql_fetch_assoc($rsIade));
     $rows = mysql_num_rows($rsIade);
     if($rows > 0) {
     mysql_data_seek($rsIade, 0);
     $row_rsIade = mysql_fetch_assoc($rsIade);
     }
     ?>
     </select>
     </p>
     <p>
     <label for="num_bloc">Numero Bloc :</label>
     <select name="num_bloc" id="num_bloc" accesskey="b" tabindex="4">
     <?php
     do { 
     ?>
     <option value="<?php echo $row_rsbloc['num_bloc']?>"><?php echo $row_rsbloc['num_bloc']?></option>
     <?php
     } while ($row_rsbloc = mysql_fetch_assoc($rsbloc));
     $rows = mysql_num_rows($rsbloc);
     if($rows > 0) {
     mysql_data_seek($rsbloc, 0);
     $row_rsbloc = mysql_fetch_assoc($rsbloc);
     }
     ?>
     </select>
     </p>
     <p>
     <label for="dat">Date :</label>
    
     <input type="text" id="datepicker" name="datepicker" />
     </p>
     <p>&nbsp;</p>
     <p>
     <input type="submit" name="envoi" id="envoi" value="Ajout d'une vacation" accesskey="e" tabindex="6" />
     </p>
     <p>&nbsp;</p>
     <input type="hidden" name="MM_insert" value="ajout-vacations" />
     </form>
     <p>&nbsp;</p>
     </body>
     </html>
     <?php
     mysql_free_result($rsIade);
    
     mysql_free_result($rsbloc);
     ?>
    j'espère que ça va t'aider, Cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

  16. #16
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb Datepicker -Fin
    Salut,

    cela marche tres bien

    Merci de ton aide

    Raphael

  17. #17
    Membre éclairé
    Avatar de buggen25
    Ingénieur développement logiciels
    Inscrit en
    Août 2008
    Messages
    554
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Août 2008
    Messages : 554
    Points : 709
    Points
    709
    Par défaut
    De rien n'oublie pas de mettre résolu cordialement
    If you type Google into Google, you Can break the internet" - The IT Crowd

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [DOM] [Xerces] Insertion d'une entité
    Par Traroth dans le forum Format d'échange (XML, JSON...)
    Réponses: 10
    Dernier message: 19/05/2008, 09h28
  2. Bulk insert et caractère accentué
    Par slc dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 22/04/2003, 12h52
  3. probleme d'insertion d'un Float
    Par neness dans le forum Débuter
    Réponses: 3
    Dernier message: 07/01/2003, 12h32
  4. [Postgresql] pb lors d'insertion de données
    Par bob20000 dans le forum Requêtes
    Réponses: 8
    Dernier message: 04/11/2002, 15h33
  5. Réponses: 4
    Dernier message: 28/09/2002, 00h00

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