par
veandell » 04 juin 2011, 01:52
Bonsoir,je suis nouveau sur se forum
Je coince sur mon code depuis plusieurs jours,je vais essayer de vous expliquez se problèmes,donc j'ai un formulaire avec différents nom, prix et stock et une image,
ex:manga_neuf:naruto;prix : 6€ normalement c'est 6€95,mais je ne sais pas encore utilisé les décimal,son stock:10 et l'image du livre,
j'insert tout sa dans ma bdd mais je voudrais faire l'update du manga en rapport a son prix ou son stock ,bien sur je n'ai pas que le livre,j'ai aussi des jeux,figurine etc
je vous met mon code
<?php
Session_start();
include('../tests/cookie.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Aux milles trésors du dragon</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title= "site" href="../css/site.css" />
</head>
<?php
include("../includes/pseudo.php");
include("../includes/functions.php");
include("../includes/constants.php");
include("../includes/identifiants.php");
$jeu_neuf = htmlspecialchars(addslashes($_POST['jeu_neuf']));
$manga_neuf = htmlspecialchars(addslashes($_POST['manga_neuf']));
$figurine_neuf = htmlspecialchars(addslashes($_POST['figurine_neuf']));
$console_neuf = htmlspecialchars(addslashes($_POST['console_neuf']));
$dvd_neuf = htmlspecialchars(addslashes($_POST['dvd_neuf']));
$prix_jeu_neuf = htmlspecialchars(addslashes($_POST['prix_jeu_neuf']));
$prix_manga_neuf = htmlspecialchars(addslashes($_POST['prix_manga_neuf']));
$prix_figurine_neuf = htmlspecialchars(addslashes($_POST['prix_figurine_neuf']));
$prix_console_neuf = htmlspecialchars(addslashes($_POST['prix_console_neuf']));
$prix_dvd_neuf = htmlspecialchars(addslashes($_POST['prix_dvd_neuf']));
$stock_jeu_neuf = htmlspecialchars(addslashes($_POST['stock_jeu_neuf']));
$stock_manga_neuf = htmlspecialchars(addslashes($_POST['stock_manga_neuf']));
$stock_figurine_neuf = htmlspecialchars(addslashes($_POST['stock_figurine_neuf']));
$stock_console_neuf = htmlspecialchars(addslashes($_POST['stock_console_neuf']));
$stock_dvd_neuf = htmlspecialchars(addslashes($_POST['stock_dvd_neuf']));
$query = $db->prepare("SELECT id,jeu_neuf,manga_neuf,figurine_neuf,console_neuf,dvd_neuf FROM `magasin` WHERE
prix_jeu_neuf = :prix_jeu_neuf");
$query->bindValue(':prix_jeu_neuf', $_POST['prix_jeu_neuf'], PDO::PARAM_INT);
$query->execute();
$data = $query->fetch();
print_r($data);
if (!empty($_FILES['image']['size']))
{
//On définit les variables :
$maxsize = 35000; //Poid de l'image
$maxwidth = 300; //Largeur de l'image
$maxheight = 300; //Longueur de l'image
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'bmp' ); //Liste des extensions valides
if ($_FILES['image']['error'] > 0)
{
$avatar_erreur = "Erreur lors du tranfsert de l'avatar : ";
}
if ($_FILES['image']['size'] > $maxsize)
{
$i++;
$image_erreur1 = "Le fichier est trop gros : (<strong>".$_FILES['image']['size']." Octets</strong> contre <strong>".$maxsize." Octets</strong>)";
}
$image_sizes = getimagesize($_FILES['image']['tmp_name']);
if ($image_sizes[0] > $maxwidth OR $image_sizes[1] > $maxheight)
{
$i++;
$image_erreur2 = "Image trop large ou trop longue :
(<strong>".$image_sizes[0]."x".$image_sizes[1]."</strong> contre <strong>".$maxwidth."x".$maxheight."</strong>)";
}
$extension_upload = strtolower(substr( strrchr($_FILES['image']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$i++;
$image_erreur3 = "Extension de l'avatar incorrecte";
}
}
$nomimage=(!empty($_FILES['image']['size']))?move_image($_FILES['image']):'';
$query = $db->prepare("SELECT COUNT(*) AS nombre_entree FROM `magasin` WHERE id = :id");
$query->bindValue(':id', $data['id'], PDO::PARAM_INT);
$query->execute();
$donnees = $query->fetch();
$nombre_lignes = $donnees['nombre_entree'];
print_r ($donnees);
if ($nombre_lignes > 0)
{
$query = $db->prepare('INSERT INTO magasin (jeu_neuf,console_neuf,manga_neuf,image,
figurine_neuf,dvd_neuf,prix_jeu_neuf,prix_console_neuf,
prix_manga_neuf,prix_figurine_neuf,
prix_dvd_neuf,stock_jeu_neuf,stock_console_neuf,
stock_manga_neuf,stock_figurine_neuf,stock_dvd_neuf)
VALUES (:jeu_neuf,:console_neuf,:manga_neuf,:nomimage,:figurine_neuf,:dvd_neuf,
:prix_jeu_neuf,:prix_console_neuf,:prix_manga_neuf,:prix_figurine_neuf,
:prix_dvd_neuf,:stock_jeu_neuf,:stock_console_neuf,
:stock_manga_neuf,:stock_figurine_neuf,:stock_dvd_neuf)
');
$query->bindvalue(':jeu_neuf', $jeu_neuf, pdo::PARAM_STR);
$query->bindvalue(':console_neuf', $console_neuf, pdo::PARAM_STR);
$query->bindvalue(':manga_neuf', $manga_neuf, pdo::PARAM_STR);
$query->bindvalue(':figurine_neuf', $figurine_neuf, pdo::PARAM_STR);
$query->bindvalue(':dvd_neuf', $dvd_neuf, pdo::PARAM_STR);
$query->bindvalue(':prix_jeu_neuf', $prix_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_console_neuf', $prix_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_manga_neuf', $prix_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_figurine_neuf', $prix_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_jeu_neuf', $stock_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_console_neuf', $stock_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_manga_neuf', $stock_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_figurine_neuf', $stock_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':nomimage', $nomimage, pdo::PARAM_STR);
$query->execute() or die(print_r($db->errorinfo()));
$query->CloseCursor();
}else{
$query = $db->prepare('UPDATE magasin
SET jeu_neuf = :jeu_neuf,
console_neuf = :console_neuf,
manga_neuf = :manga_neuf,
figurine_neuf =:figurine_neuf,
dvd_neuf = :dvd_neuf,
prix_jeu_neuf = :prix_jeu_neuf,
prix_console_neuf = :prix_console_neuf,
prix_manga_neuf = :prix_manga_neuf,
prix_figurine_neuf =:prix_figurine_neuf,
prix_dvd_neuf = :prix_dvd_neuf,
stock_jeu_neuf = :stock_jeu_neuf,
stock_console_neuf = :stock_console_neuf,
stock_manga_neuf = :stock_manga_neuf,
stock_figurine_neuf = :stock_figurine_neuf,
stock_dvd_neuf = :stock_dvd_neuf
WHERE id = :id
');
$query->bindvalue(':id',$data['id'], pdo::PARAM_INT);
$query->bindvalue(':jeu_neuf', $jeu_neuf, pdo::PARAM_STR);
$query->bindvalue(':console_neuf', $console_neuf, pdo::PARAM_STR);
$query->bindvalue(':manga_neuf', $manga_neuf, pdo::PARAM_STR);
$query->bindvalue(':figurine_neuf', $figurine_neuf, pdo::PARAM_STR);
$query->bindvalue(':dvd_neuf', $dvd_neuf, pdo::PARAM_STR);
$query->bindvalue(':prix_jeu_neuf', $prix_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_console_neuf', $prix_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_manga_neuf', $prix_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_figurine_neuf', $prix_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_jeu_neuf', $stock_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_console_neuf', $stock_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_manga_neuf', $stock_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_figurine_neuf', $stock_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->execute() or die(print_r($db->errorinfo()));
$query->CloseCursor();
}
echo'<h1>donnée rentré</h1>';
echo'<p>donnée bien rentré</p>
<p>cliquez <a href = "../tests/magasin.php">ici</a> </p>';
?>
</div>
</body>
</html>
si vous avez besoin de renseignement,je suis dispo
merci de votre aide
Bonsoir,je suis nouveau sur se forum
Je coince sur mon code depuis plusieurs jours,je vais essayer de vous expliquez se problèmes,donc j'ai un formulaire avec différents nom, prix et stock et une image,
ex:manga_neuf:naruto;prix : 6€ normalement c'est 6€95,mais je ne sais pas encore utilisé les décimal,son stock:10 et l'image du livre,
j'insert tout sa dans ma bdd mais je voudrais faire l'update du manga en rapport a son prix ou son stock ,bien sur je n'ai pas que le livre,j'ai aussi des jeux,figurine etc
je vous met mon code[php] <?php
Session_start();
include('../tests/cookie.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Aux milles trésors du dragon</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title= "site" href="../css/site.css" />
</head>
<?php
include("../includes/pseudo.php");
include("../includes/functions.php");
include("../includes/constants.php");
include("../includes/identifiants.php");
$jeu_neuf = htmlspecialchars(addslashes($_POST['jeu_neuf']));
$manga_neuf = htmlspecialchars(addslashes($_POST['manga_neuf']));
$figurine_neuf = htmlspecialchars(addslashes($_POST['figurine_neuf']));
$console_neuf = htmlspecialchars(addslashes($_POST['console_neuf']));
$dvd_neuf = htmlspecialchars(addslashes($_POST['dvd_neuf']));
$prix_jeu_neuf = htmlspecialchars(addslashes($_POST['prix_jeu_neuf']));
$prix_manga_neuf = htmlspecialchars(addslashes($_POST['prix_manga_neuf']));
$prix_figurine_neuf = htmlspecialchars(addslashes($_POST['prix_figurine_neuf']));
$prix_console_neuf = htmlspecialchars(addslashes($_POST['prix_console_neuf']));
$prix_dvd_neuf = htmlspecialchars(addslashes($_POST['prix_dvd_neuf']));
$stock_jeu_neuf = htmlspecialchars(addslashes($_POST['stock_jeu_neuf']));
$stock_manga_neuf = htmlspecialchars(addslashes($_POST['stock_manga_neuf']));
$stock_figurine_neuf = htmlspecialchars(addslashes($_POST['stock_figurine_neuf']));
$stock_console_neuf = htmlspecialchars(addslashes($_POST['stock_console_neuf']));
$stock_dvd_neuf = htmlspecialchars(addslashes($_POST['stock_dvd_neuf']));
$query = $db->prepare("SELECT id,jeu_neuf,manga_neuf,figurine_neuf,console_neuf,dvd_neuf FROM `magasin` WHERE
prix_jeu_neuf = :prix_jeu_neuf");
$query->bindValue(':prix_jeu_neuf', $_POST['prix_jeu_neuf'], PDO::PARAM_INT);
$query->execute();
$data = $query->fetch();
print_r($data);
if (!empty($_FILES['image']['size']))
{
//On définit les variables :
$maxsize = 35000; //Poid de l'image
$maxwidth = 300; //Largeur de l'image
$maxheight = 300; //Longueur de l'image
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'bmp' ); //Liste des extensions valides
if ($_FILES['image']['error'] > 0)
{
$avatar_erreur = "Erreur lors du tranfsert de l'avatar : ";
}
if ($_FILES['image']['size'] > $maxsize)
{
$i++;
$image_erreur1 = "Le fichier est trop gros : (<strong>".$_FILES['image']['size']." Octets</strong> contre <strong>".$maxsize." Octets</strong>)";
}
$image_sizes = getimagesize($_FILES['image']['tmp_name']);
if ($image_sizes[0] > $maxwidth OR $image_sizes[1] > $maxheight)
{
$i++;
$image_erreur2 = "Image trop large ou trop longue :
(<strong>".$image_sizes[0]."x".$image_sizes[1]."</strong> contre <strong>".$maxwidth."x".$maxheight."</strong>)";
}
$extension_upload = strtolower(substr( strrchr($_FILES['image']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$i++;
$image_erreur3 = "Extension de l'avatar incorrecte";
}
}
$nomimage=(!empty($_FILES['image']['size']))?move_image($_FILES['image']):'';
$query = $db->prepare("SELECT COUNT(*) AS nombre_entree FROM `magasin` WHERE id = :id");
$query->bindValue(':id', $data['id'], PDO::PARAM_INT);
$query->execute();
$donnees = $query->fetch();
$nombre_lignes = $donnees['nombre_entree'];
print_r ($donnees);
if ($nombre_lignes > 0)
{
$query = $db->prepare('INSERT INTO magasin (jeu_neuf,console_neuf,manga_neuf,image,
figurine_neuf,dvd_neuf,prix_jeu_neuf,prix_console_neuf,
prix_manga_neuf,prix_figurine_neuf,
prix_dvd_neuf,stock_jeu_neuf,stock_console_neuf,
stock_manga_neuf,stock_figurine_neuf,stock_dvd_neuf)
VALUES (:jeu_neuf,:console_neuf,:manga_neuf,:nomimage,:figurine_neuf,:dvd_neuf,
:prix_jeu_neuf,:prix_console_neuf,:prix_manga_neuf,:prix_figurine_neuf,
:prix_dvd_neuf,:stock_jeu_neuf,:stock_console_neuf,
:stock_manga_neuf,:stock_figurine_neuf,:stock_dvd_neuf)
');
$query->bindvalue(':jeu_neuf', $jeu_neuf, pdo::PARAM_STR);
$query->bindvalue(':console_neuf', $console_neuf, pdo::PARAM_STR);
$query->bindvalue(':manga_neuf', $manga_neuf, pdo::PARAM_STR);
$query->bindvalue(':figurine_neuf', $figurine_neuf, pdo::PARAM_STR);
$query->bindvalue(':dvd_neuf', $dvd_neuf, pdo::PARAM_STR);
$query->bindvalue(':prix_jeu_neuf', $prix_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_console_neuf', $prix_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_manga_neuf', $prix_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_figurine_neuf', $prix_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_jeu_neuf', $stock_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_console_neuf', $stock_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_manga_neuf', $stock_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_figurine_neuf', $stock_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':nomimage', $nomimage, pdo::PARAM_STR);
$query->execute() or die(print_r($db->errorinfo()));
$query->CloseCursor();
}else{
$query = $db->prepare('UPDATE magasin
SET jeu_neuf = :jeu_neuf,
console_neuf = :console_neuf,
manga_neuf = :manga_neuf,
figurine_neuf =:figurine_neuf,
dvd_neuf = :dvd_neuf,
prix_jeu_neuf = :prix_jeu_neuf,
prix_console_neuf = :prix_console_neuf,
prix_manga_neuf = :prix_manga_neuf,
prix_figurine_neuf =:prix_figurine_neuf,
prix_dvd_neuf = :prix_dvd_neuf,
stock_jeu_neuf = :stock_jeu_neuf,
stock_console_neuf = :stock_console_neuf,
stock_manga_neuf = :stock_manga_neuf,
stock_figurine_neuf = :stock_figurine_neuf,
stock_dvd_neuf = :stock_dvd_neuf
WHERE id = :id
');
$query->bindvalue(':id',$data['id'], pdo::PARAM_INT);
$query->bindvalue(':jeu_neuf', $jeu_neuf, pdo::PARAM_STR);
$query->bindvalue(':console_neuf', $console_neuf, pdo::PARAM_STR);
$query->bindvalue(':manga_neuf', $manga_neuf, pdo::PARAM_STR);
$query->bindvalue(':figurine_neuf', $figurine_neuf, pdo::PARAM_STR);
$query->bindvalue(':dvd_neuf', $dvd_neuf, pdo::PARAM_STR);
$query->bindvalue(':prix_jeu_neuf', $prix_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_console_neuf', $prix_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_manga_neuf', $prix_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_figurine_neuf', $prix_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':prix_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_jeu_neuf', $stock_jeu_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_console_neuf', $stock_console_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_manga_neuf', $stock_manga_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_figurine_neuf', $stock_figurine_neuf, pdo::PARAM_INT);
$query->bindvalue(':stock_dvd_neuf', $prix_dvd_neuf, pdo::PARAM_INT);
$query->execute() or die(print_r($db->errorinfo()));
$query->CloseCursor();
}
echo'<h1>donnée rentré</h1>';
echo'<p>donnée bien rentré</p>
<p>cliquez <a href = "../tests/magasin.php">ici</a> </p>';
?>
</div>
</body>
</html>
[/php]
si vous avez besoin de renseignement,je suis dispo
merci de votre aide