Update champ image comment faire
ideal23
Messages postés
505
Statut
Membre
-
ideal23 Messages postés 505 Statut Membre -
ideal23 Messages postés 505 Statut Membre -
Bonjour,
je suis entrain de créer mon espace administration. je veux pouvoir modifier une table avec un champ image. voici le code:
Lorsque je modifie un champ autre que celui de la photo, le résultat est bon , mais en même temps, la donnée du champ photo est supprimée. Je suis obligé de faire un 2ème passage pour remettre la photo.
j'ai pensé à faire une vérification sur le champ photo. S'il est vide, on ne le change pas, sinon on le change.
nouveau code:
Maintenant effectivement je peux modifier les autres champs sans que le champ photo soit supprimé. Mais je ne peux plus modifier le champ photo lui-même.
Je ne comprends pas ce résultat.avez-vous une idée pour modifier ce champ image Merci
je suis entrain de créer mon espace administration. je veux pouvoir modifier une table avec un champ image. voici le code:
<?php require_once('../Connections/dream.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE articles SET titre=%s, 'description'=%s, prix=%s, photo=%s WHERE reference=%s",
GetSQLValueString($_POST['titre'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "double"),
GetSQLValueString($_POST['photo'], "text"),
GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_dream, $dream);
$Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
$updateGoTo = "valider.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Rsmodifclient = "-1";
if (isset($_GET['reference'])) {
$colname_Rsmodifclient = $_GET['reference'];
}
mysql_select_db($database_dream, $dream);
$query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
$Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
$row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
$totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient);
?>
Lorsque je modifie un champ autre que celui de la photo, le résultat est bon , mais en même temps, la donnée du champ photo est supprimée. Je suis obligé de faire un 2ème passage pour remettre la photo.
j'ai pensé à faire une vérification sur le champ photo. S'il est vide, on ne le change pas, sinon on le change.
nouveau code:
<?php require_once('../Connections/dream.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$colname_Rsmodifclient = "-1";
if (isset($_GET['reference'])) {
$colname_Rsmodifclient = $_GET['reference'];
}
mysql_select_db($database_dream, $dream);
$query_Rsmodifclient = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_Rsmodifclient, "int"));
$Rsmodifclient = mysql_query($query_Rsmodifclient, $dream) or die(mysql_error());
$row_Rsmodifclient = mysql_fetch_assoc($Rsmodifclient);
$totalRows_Rsmodifclient = mysql_num_rows($Rsmodifclient);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if (empty($_POST['photo'])) {
$updateSQL = sprintf("UPDATE articles SET titre=%s, 'description'=%s, prix=%s WHERE reference=%s",
GetSQLValueString($_POST['titre'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "double"),
GetSQLValueString($_POST['ID'], "int"));
}
else
{
$updateSQL = sprintf("UPDATE articles SET titre=%s, description'=%s, prix=%s, photo=%s WHERE reference=%s",
GetSQLValueString($_POST['titre'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "double"),
GetSQLValueString($_POST['photo'], "text"),
GetSQLValueString($_POST['ID'], "int"));
}
mysql_select_db($database_dream, $dream);
$Result1 = mysql_query($updateSQL, $dream) or die(mysql_error());
$updateGoTo = "valider.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?>
Maintenant effectivement je peux modifier les autres champs sans que le champ photo soit supprimé. Mais je ne peux plus modifier le champ photo lui-même.
Je ne comprends pas ce résultat.avez-vous une idée pour modifier ce champ image Merci
A voir également:
- Please update to the authorized images
- Windows update bloqué - Guide
- Qwerty to azerty - Guide
- Winget update - Guide
- Asus live update - Télécharger - Utilitaires
- Des images - Guide