J'ai un petit soucis sur une page de formulaire que je dois modifié pour y insérer un fonction qui détecte les retours à la ligne et les modidifient en BR. Voici le code PHP d'insertion des données dans la base :
<?
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($editFormAction)) {
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
if (!eregi("GP_upload=true", $HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "&GP_upload=true";
}
}
else {
$editFormAction .= "?GP_upload=true";
}
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE examens SET titre=%s, recus=%s WHERE id=%s",
GetSQLValueString($_POST['titre'], "text"),
GetSQLValueString($_POST['recus'], "text"),
GetSQLValueString($_POST['id'], "int"));
$recus=nl2br($recus);
mysql_select_db($database_ac_connect, $ac_connect);
$Result1 = mysql_query($updateSQL, $ac_connect) or die(mysql_error());
$updateGoTo = "gestion_module.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?>
Et voici la nouvelle fonction à insérer :Code : Tout sélectionner
$recus=nl2br($recus);Quelqu'un pour me venir en aide SVP ? I'm lost !