par
kdidot » 06 sept. 2013, 18:46
Bonjour,
j'ai enfait un petit problème avec l'ajout d'une nouvelle entrée dans ma base de données. J'aimerais enfait tout simplement ajouter une image, qui sera redimensionné à l'upload. Le redimensionnement et tout marche. C'est juste que lorsque j'essaye d'ajouter une nouvelle entrée, je reçois le message suivant:
( ! ) SCREAM: Error suppression ignored for
( ! ) Notice: Undefined index: photo in C:\wamp\www\martinjakob\admin\add_photos\add_photos_travaux.php on line 46
Ce qui est étonnant parce que pour mes autres pages tout fonctionne. Voici le code php de ma page. Cela fait 2h que j'essaye de trouver l'erreur, sans succès.
Si vous pouviez m'aider et m'expliquer l'erreur ce ne serait pas refus.
Merci pour tout et pour ce forum

.
Kévin
<?php require_once('../../Connections/conn.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']);
}
// Test si le formulaire a bien été envoyé
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{
//récupère et redimensionne la photo
$photodir='../../gallery/images/';
$photo="";
$type_photo = $_FILES['photo']['type'];
//vérifie que la photo soit au bon format
if(!(strstr($type_photo,'jpg') or strstr($type_photo,'jpeg') or strstr($type_photo,'bmp') or strstr($type_photo,'gif') or strstr($type_photo,'png')))
{
exit("L'image n'est pas compatible ou est trop lourde.");
}
//vérifie que l'upload s'est bien passée
$the_image=$photodir.$_FILES['photo']['name'];
$the_image_big=$photodir."big_".$_FILES['photo']['name'];
$i="";
while(file_exists($the_image_big)){
$i+=1;
$the_image=$photodir.$i.$_FILES['photo']['name'];
$the_image_big=$photodir."big_".$i.$_FILES['photo']['name'];
}
if(move_uploaded_file($_FILES['photo']['tmp_name'], $the_image))
{
$photo=$i.$_FILES['photo']['name'];
list($width, $height, $type, $attr) = getimagesize($photodir.$photo);
// si la vignette est horizontale
if($width>=$height)
{
creation_vignette($photo , 96 , 250 , $photodir , $photodir , "small_");
creation_vignette($photo , 400 , 1000 , $photodir , $photodir , "big_");
}
// si la vignette est verticale
if($width<=$height)
{
creation_vignette($photo , 96 , 250 , $photodir , $photodir , "small_");
creation_vignette($photo , 400 , 1000 , $photodir , $photodir , "big_");
}
//efface l'originale
if($photo!="")
{
chmod($photodir.$photo,0777);
unlink($photodir.$photo);
}
}
$insertSQL = sprintf("INSERT INTO photos (id, photo) VALUES (%s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($photo, "text"));
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "gestion_photos_travaux.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conn, $conn);
$query_travaux = "SELECT * FROM travaux ORDER BY nom ASC";
$travaux = mysql_query($query_travaux, $conn) or die(mysql_error());
$row_travaux = mysql_fetch_assoc($travaux);
$totalRows_travaux = mysql_num_rows($travaux);
?>
Bonjour,
j'ai enfait un petit problème avec l'ajout d'une nouvelle entrée dans ma base de données. J'aimerais enfait tout simplement ajouter une image, qui sera redimensionné à l'upload. Le redimensionnement et tout marche. C'est juste que lorsque j'essaye d'ajouter une nouvelle entrée, je reçois le message suivant:
[b]( ! ) SCREAM: Error suppression ignored for
( ! ) Notice: Undefined index: photo in C:\wamp\www\martinjakob\admin\add_photos\add_photos_travaux.php on line 46[/b]
Ce qui est étonnant parce que pour mes autres pages tout fonctionne. Voici le code php de ma page. Cela fait 2h que j'essaye de trouver l'erreur, sans succès.
Si vous pouviez m'aider et m'expliquer l'erreur ce ne serait pas refus.
Merci pour tout et pour ce forum :).
Kévin
[php]<?php require_once('../../Connections/conn.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']);
}
// Test si le formulaire a bien été envoyé
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{
//récupère et redimensionne la photo
$photodir='../../gallery/images/';
$photo="";
$type_photo = $_FILES['photo']['type'];
//vérifie que la photo soit au bon format
if(!(strstr($type_photo,'jpg') or strstr($type_photo,'jpeg') or strstr($type_photo,'bmp') or strstr($type_photo,'gif') or strstr($type_photo,'png')))
{
exit("L'image n'est pas compatible ou est trop lourde.");
}
//vérifie que l'upload s'est bien passée
$the_image=$photodir.$_FILES['photo']['name'];
$the_image_big=$photodir."big_".$_FILES['photo']['name'];
$i="";
while(file_exists($the_image_big)){
$i+=1;
$the_image=$photodir.$i.$_FILES['photo']['name'];
$the_image_big=$photodir."big_".$i.$_FILES['photo']['name'];
}
if(move_uploaded_file($_FILES['photo']['tmp_name'], $the_image))
{
$photo=$i.$_FILES['photo']['name'];
list($width, $height, $type, $attr) = getimagesize($photodir.$photo);
// si la vignette est horizontale
if($width>=$height)
{
creation_vignette($photo , 96 , 250 , $photodir , $photodir , "small_");
creation_vignette($photo , 400 , 1000 , $photodir , $photodir , "big_");
}
// si la vignette est verticale
if($width<=$height)
{
creation_vignette($photo , 96 , 250 , $photodir , $photodir , "small_");
creation_vignette($photo , 400 , 1000 , $photodir , $photodir , "big_");
}
//efface l'originale
if($photo!="")
{
chmod($photodir.$photo,0777);
unlink($photodir.$photo);
}
}
$insertSQL = sprintf("INSERT INTO photos (id, photo) VALUES (%s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($photo, "text"));
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "gestion_photos_travaux.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conn, $conn);
$query_travaux = "SELECT * FROM travaux ORDER BY nom ASC";
$travaux = mysql_query($query_travaux, $conn) or die(mysql_error());
$row_travaux = mysql_fetch_assoc($travaux);
$totalRows_travaux = mysql_num_rows($travaux);
?>[/php]