Insertion ds la base de donnee

Résolu/Fermé
120984fares - 6 juin 2011 à 12:43
Leviathan49 Messages postés 257 Date d'inscription jeudi 10 juin 2010 Statut Membre Dernière intervention 22 juillet 2011 - 6 juin 2011 à 13:43
Bonjour,

j'ai un formuir qui a un champs texte qui resois la date d'appre un calandrier mais je n'arreve pas ainserer cete date ds la base le code est le suivent:


<?php require_once('Connections/bdd.php'); ?>
<?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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$val = NULL;
$insertSQL = sprintf("INSERT INTO date (DATE) VALUES (%s)",
GetSQLValueString($val, "date"));

mysql_select_db($database_bdd, $bdd);
$Result1 = mysql_query($insertSQL, $bdd) or die(mysql_error());
}

mysql_select_db($database_bdd, $bdd);
$query_Recordset1 = "SELECT * FROM 'date'";
$Recordset1 = mysql_query($query_Recordset1, $bdd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>Document sans titre</title>
<link href="../style/default.css" rel="stylesheet" type="text/css" />

</head>

<body>

<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data"><td height="30" align="left" class="txt_1">Date</td>
<td align="left"><label>
<input name="DATE" type="text" class="line_4" id="date" <?php if (isset($show_document)) echo 'value="'.date_fr($show_document['doc_creat_date']).'"' ; else echo 'value="'.$date = date("d-m-Y").'"'; ?> >
<a href="#" onclick=" window.open('lib/calendar/calendar.php?frm=form1&ch=date','calendrier','width=350,height=160,scrollbars=0').focus();">
<img src="imgs/date.png" width="22" height="22" border="0" align="absmiddle" /> </a></label></td>
</tr>

<td><input type="submit" value="Insérer l'enregistrement"></td>
</tr>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

1 réponse

Leviathan49 Messages postés 257 Date d'inscription jeudi 10 juin 2010 Statut Membre Dernière intervention 22 juillet 2011 70
6 juin 2011 à 13:43
Tu as affiché ta requête avant de l'exécuter ?
Si non, met un petit echo $insertSQL; ôn en saura déjà plus.
0