je sais, vous allez me dire de chercher dans les sujets du forum et dans la FAQ, la réponse s'y trouve.
Je vous rassure, c'est chose faite. J'ai épluché tous les posts concernant cette erreur, j'ai appliqué les conseils que j'y ai trouvé ( suppression des espaces, pas de code html avant, ni dans le fichier appelé par include, etc ...) et pourtant j'ai toujours la même erreur :
Le plus surprenant, c'est que j'ai fameux "header" dans mon premier fichier (insert_individu.php) qui redirige vers le second fichier (insert_naissance.php) qui fonctionne, après validation, ça marche mais pas après validation du second formulaire (dans insert_naissance.php) pour diriger vers le fichier suivant (insert_mariage.php).Warning: Cannot modify header information - headers already sent by (output started at d:\easyphp1-8\www\genealogie\insert_naissance.php:1) in d:\easyphp1-8\www\genealogie\insert_naissance.php on line 52
Les lignes de codes sont pour moi identiques, à l'exception des requêtes bien sûr. Voici le début des 2 fichiers :
insert_individu.php
<?php require_once('Connections/genealogie.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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "insert_individu")) {
$insertSQL = sprintf("INSERT INTO liste_individus (Sosa, Generation, Nom, Prenom1, Prenom2, Prenom3, Sexe, photo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['sosa'], "int"),
GetSQLValueString($HTTP_POST_VARS['generation'], "int"),
GetSQLValueString($HTTP_POST_VARS['nom'], "text"),
GetSQLValueString($HTTP_POST_VARS['prenom1'], "text"),
GetSQLValueString($HTTP_POST_VARS['prenom2'], "text"),
GetSQLValueString($HTTP_POST_VARS['prenom3'], "text"),
GetSQLValueString($HTTP_POST_VARS['sexe'], "text"),
GetSQLValueString($HTTP_POST_VARS['photo'], "int"));
mysql_select_db($database_genealogie, $genealogie);
$Result1 = mysql_query($insertSQL, $genealogie) or die(mysql_error());
$insertGoTo = "insert_naissance.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo)); /* LIGNE 52 */
}
?>
insertion_naissance.php<?php require_once('Connections/genealogie.php');?>
<?php
/* REQUETE D'INSERTION DANS LA BASE DE DONNEES */
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_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "insert_naissance")) {
$insertSQL = sprintf("INSERT INTO liste_naissances (Type, Ref_individu, naiss_jour, naiss_mois, naiss_annee, Ref_commune, Poss_acte) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['insert_type'], "text"),
GetSQLValueString($HTTP_POST_VARS['id_individu'], "int"),
GetSQLValueString($HTTP_POST_VARS['jour_naiss'], "int"),
GetSQLValueString($HTTP_POST_VARS['mois_naiss'], "int"),
GetSQLValueString($HTTP_POST_VARS['annee_naiss'], "int"),
GetSQLValueString($HTTP_POST_VARS['commune_naiss'], "int"),
GetSQLValueString($HTTP_POST_VARS['possession_acte_naiss'], "int"));
mysql_select_db($database_genealogie, $genealogie);
$Result1 = mysql_query($insertSQL, $genealogie) or die(mysql_error());
$insertGoTo = "insert_mariage.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo)); /* LIGNE 52 */
}
/* FIN DE REQUETE D'INSERTION DANS LA BASE DE DONNEES */
?>
Le fait de laisser ou de supprimer les espaces ou les retours chariot dans le code PHP ne change absolument rien.A mon avis le problème vient peut-être de la variable %s appelée par le header du deuxième fichier, mais j'ai essayé de la changer et rien n'y fait non plus.
Je coince et je demande un peu d'aide, SVP.