Stockage des image dans la base de donnee
passage
-
ria -
ria -
Bonjour,
j'ai un petit probleme je veux stocker des images dans la base de donner mais tjr me donne cette phrase quand je fais parcourir
=========================================================================
Notice: Undefined index: file in c:\program files\easyphp1-7\www\test.php on line 35
Le champ 'photo' ne peut être vide (null)
=========================================================================
la page conecter.php
-----------------------------------------------------
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conecter = "localhost";
$database_conecter = "image";
$username_conecter = "root";
$password_conecter = "";
$conecter = mysql_pconnect($hostname_conecter, $username_conecter, $password_conecter) or trigger_error(mysql_error(),E_USER_ERROR);
?>
=========================================================================
voila mon code sur ma page test.php :
-------------------------------------------------------
<?php require_once('Connections/conecter.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 = $_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 photo (photo) VALUES (%s)",
GetSQLValueString($_POST['file'], "text"));
mysql_select_db($database_conecter, $conecter);
$Result1 = mysql_query($insertSQL, $conecter) or die(mysql_error());
$insertGoTo = "test.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conecter, $conecter);
$query_Recordset1 = "SELECT * FROM photo ORDER BY id DESC";
$Recordset1 = mysql_query($query_Recordset1, $conecter) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="file">
<input type="submit" name="Submit" value="Envoyer"></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="form1">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img name="" src="<?php echo $row_Recordset1['photo']; ?>" alt=""></td>
</tr>
</table>
<p> </p>
<?php
mysql_free_result($Recordset1);
?>
j'ai un petit probleme je veux stocker des images dans la base de donner mais tjr me donne cette phrase quand je fais parcourir
=========================================================================
Notice: Undefined index: file in c:\program files\easyphp1-7\www\test.php on line 35
Le champ 'photo' ne peut être vide (null)
=========================================================================
la page conecter.php
-----------------------------------------------------
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conecter = "localhost";
$database_conecter = "image";
$username_conecter = "root";
$password_conecter = "";
$conecter = mysql_pconnect($hostname_conecter, $username_conecter, $password_conecter) or trigger_error(mysql_error(),E_USER_ERROR);
?>
=========================================================================
voila mon code sur ma page test.php :
-------------------------------------------------------
<?php require_once('Connections/conecter.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 = $_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 photo (photo) VALUES (%s)",
GetSQLValueString($_POST['file'], "text"));
mysql_select_db($database_conecter, $conecter);
$Result1 = mysql_query($insertSQL, $conecter) or die(mysql_error());
$insertGoTo = "test.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conecter, $conecter);
$query_Recordset1 = "SELECT * FROM photo ORDER BY id DESC";
$Recordset1 = mysql_query($query_Recordset1, $conecter) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="file">
<input type="submit" name="Submit" value="Envoyer"></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="form1">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img name="" src="<?php echo $row_Recordset1['photo']; ?>" alt=""></td>
</tr>
</table>
<p> </p>
<?php
mysql_free_result($Recordset1);
?>
Configuration: Windows XP Internet Explorer 6.0
5 réponses
-
-
Bonjour,
svp j'ai pas compris ce que tu ma ecris es ce que vous pouver m'expliquer avec les detail si vous vouler
merci -
Bonjour,
Il faudrait que tu nous donnes la structure de ta table photo.
Xavier -
Bonjour,
voila ma table
================================
CREATE TABLE `photo` (
`id` INT NOT NULL AUTO_INCREMENT ,
`photo` BLOB NOT NULL ,
PRIMARY KEY ( `id` )
);
================================ -
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question -