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