cox001
Nouveau membre
Bonjour,
J'ai un petit formulaire pour remplir ma base de données mais j'obtiens toujours une erreur.. je ne sais vraiment plus quoi faire...
voici le code php:
<?php require_once('Connections/maconn.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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO livreor (ch_ea_id, ch_ea_nom, ch_ea_email, ch_ea_commentaire, `ch_ea_date`) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['ch_ea_id'], "int"),
GetSQLValueString($_POST['ch_ea_nom'], "text"),
GetSQLValueString($_POST['ch_ea_email'], "text"),
GetSQLValueString($_POST['ch_ea_commentaire'], "text"),
GetSQLValueString($_POST['ch_ea_date'], "date"));
mysql_select_db($database_maconn, $maconn);
$Result1 = mysql_query($insertSQL, $maconn) or die(mysql_error());
$insertGoTo = "covoiturage.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_maconn, $maconn);
$query_commentaires = "SELECT * FROM livreor ORDER BY `ch_ea_date` DESC";
$commentaires = mysql_query($query_commentaires, $maconn) or die(mysql_error());
$row_commentaires = mysql_fetch_assoc($commentaires);
$colname_commentaires = "-1";
if (isset($_POST['ch_ea_id'])) {
$colname_commentaires = $_POST['ch_ea_id'];
}
mysql_select_db($database_maconn, $maconn);
$query_commentaires = sprintf("SELECT * FROM livreor WHERE ch_ea_id = %s", GetSQLValueString($colname_commentaires, "int"));
$commentaires = mysql_query($query_commentaires, $maconn) or die(mysql_error());
$row_commentaires = mysql_fetch_assoc($commentaires);
$totalRows_commentaires = mysql_num_rows($commentaires);
?>
et le formulaire:
<form name="form1" method="post" action="<?php echo $editFormAction; ?>"><input name="ch_ea_id" type="hidden" value="<?php echo $row_commentaires['ch_ea_id']; ?>" />
<p> </p>
<table width="473" border="1" align="center" cellpadding="1" cellspacing="1" id="centre">
<tr>
<td width="128">Nom ou pseudo</td>
<td width="332"><input name="ch_ea_nom" type="text" id="ch_ea_nom" size="56"></td>
</tr>
<tr>
<td>E-mail</td>
<td><input name="ch_ea_email" type="text" id="ch_ea_email" size="56"></td>
</tr>
<tr>
<td>Commentaire</td>
<td><textarea name="textfield" cols="56" rows="5" id="textfield"></textarea></td>
</tr>
</table>
<p> </p>
<input type="submit" name="ajout" id="ajout" value="Ajouter" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
j'obtiens l'erreur:
Notice: Undefined index: ch_ea_commentaire in C:\Users\Cox\Desktop\www\erik_anita\formulaire.php on line 44
Notice: Undefined index: ch_ea_date in C:\Users\Cox\Desktop\www\erik_anita\formulaire.php on line 45
Column count doesn't match value count at row 1
je sais pas si vous pouvez m'aider, j'y comprends plus rien mais merci d'avance..
J'ai un petit formulaire pour remplir ma base de données mais j'obtiens toujours une erreur.. je ne sais vraiment plus quoi faire...
voici le code php:
<?php require_once('Connections/maconn.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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO livreor (ch_ea_id, ch_ea_nom, ch_ea_email, ch_ea_commentaire, `ch_ea_date`) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['ch_ea_id'], "int"),
GetSQLValueString($_POST['ch_ea_nom'], "text"),
GetSQLValueString($_POST['ch_ea_email'], "text"),
GetSQLValueString($_POST['ch_ea_commentaire'], "text"),
GetSQLValueString($_POST['ch_ea_date'], "date"));
mysql_select_db($database_maconn, $maconn);
$Result1 = mysql_query($insertSQL, $maconn) or die(mysql_error());
$insertGoTo = "covoiturage.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_maconn, $maconn);
$query_commentaires = "SELECT * FROM livreor ORDER BY `ch_ea_date` DESC";
$commentaires = mysql_query($query_commentaires, $maconn) or die(mysql_error());
$row_commentaires = mysql_fetch_assoc($commentaires);
$colname_commentaires = "-1";
if (isset($_POST['ch_ea_id'])) {
$colname_commentaires = $_POST['ch_ea_id'];
}
mysql_select_db($database_maconn, $maconn);
$query_commentaires = sprintf("SELECT * FROM livreor WHERE ch_ea_id = %s", GetSQLValueString($colname_commentaires, "int"));
$commentaires = mysql_query($query_commentaires, $maconn) or die(mysql_error());
$row_commentaires = mysql_fetch_assoc($commentaires);
$totalRows_commentaires = mysql_num_rows($commentaires);
?>
et le formulaire:
<form name="form1" method="post" action="<?php echo $editFormAction; ?>"><input name="ch_ea_id" type="hidden" value="<?php echo $row_commentaires['ch_ea_id']; ?>" />
<p> </p>
<table width="473" border="1" align="center" cellpadding="1" cellspacing="1" id="centre">
<tr>
<td width="128">Nom ou pseudo</td>
<td width="332"><input name="ch_ea_nom" type="text" id="ch_ea_nom" size="56"></td>
</tr>
<tr>
<td>E-mail</td>
<td><input name="ch_ea_email" type="text" id="ch_ea_email" size="56"></td>
</tr>
<tr>
<td>Commentaire</td>
<td><textarea name="textfield" cols="56" rows="5" id="textfield"></textarea></td>
</tr>
</table>
<p> </p>
<input type="submit" name="ajout" id="ajout" value="Ajouter" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
j'obtiens l'erreur:
Notice: Undefined index: ch_ea_commentaire in C:\Users\Cox\Desktop\www\erik_anita\formulaire.php on line 44
Notice: Undefined index: ch_ea_date in C:\Users\Cox\Desktop\www\erik_anita\formulaire.php on line 45
Column count doesn't match value count at row 1
je sais pas si vous pouvez m'aider, j'y comprends plus rien mais merci d'avance..