0

I don't understand why I've got an error

"Erreur de syntaxe près de '1' à la ligne 1"

(sorry I'm french ...)

Here is my code

$post_id=$_POST["del_id"];
$post_photo=$_POST["del_photo"];

$query=mysql_query("DELETE FROM produits WHERE id='$post_id'");
$ok=mysql_query($query) or die(mysql_error());
if ($ok) {
  $small=$post_photo."_small.jpg";
  $large=$post_photo."_large.jpg";
  if (file_exists($small)) unlink($small);
  if (file_exists($large)) unlink($large);
}

However, the mysql delete works fine but my two jpg's still here due to error.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Unkilling
  • 123
  • 1
  • 2
  • 7

2 Answers2

0

To Zafar Malik : Yes the select works fine

Here is the full code

<?php
if (isset($_POST["del_id"])) {
    $post_id=mysql_real_escape_string($_POST["del_id"]);
    $post_photo=$_POST["del_photo"];

    $query=mysql_query("DELETE FROM produits WHERE id='$post_id'");
    $ok=mysql_query($query) or die(mysql_error());
    if ($ok) {
        $small=$post_photo."_small.jpg";
        $large=$post_photo."_large.jpg";
        if (file_exists($small)) unlink($small);
        if (file_exists($large)) unlink($large);
    }
    header("location: admin.php?page=produits");
}

titre_h1("NOHOME", "LISTE DES PRODUITS", "SUPPRIMER UN PRODUIT");

if (isset($_GET["id"])) {
    $get_id=$_GET["id"];
    $query = mysql_query("SELECT * FROM produits WHERE id='$get_id'");
    $nbreLignes = mysql_num_rows($query);

    echo "<div id='welcome'>\n";
    echo "<form id='formulaire' name='produits_del' action='admin.php?page=produits_del' method='post'>\n";

    if ($nbreLignes > 0) {
        $donnees = mysql_fetch_assoc($query);
        echo "<input type='hidden' name='del_id' value='".$get_id."'>\n";
        echo "<input type='hidden' name='del_photo' value='".$repimages.$donnees['photo']."'>\n";
        echo "  CONFIRMEZ-VOUS LA SUPPRESSION DU PRODUIT ?\n";
        echo "  <div class='del_name'>".iso_strtoupper_fr($donnees['nom'])."</div>\n";
        echo "  <div style='margin-bottom:15px;'>\n";
        echo "      Origine : ".$donnees['origine']."<br />\n";
        echo "      Catégorie : ".$donnees['categorie']."<br />\n";
        if ($donnees['scategorie']!='') echo "      Sous Catégorie : ".$donnees['scategorie']."<br />\n";
        echo "      <br /><img src='".$repimages.$donnees['photo']."_small.jpg' />\n";
        echo "  </div>\n";
        echo "  <div class='bouton del_bouton'><a class='valider'>SUPPRIMER</a></div>\n";
        echo "  <div class='bouton del_bouton' style='float:right;'><a class='annuler'>ANNULER</a></div>\n";
        } else {
        echo "  CE PRODUIT N'EXISTE PAS\n";
        echo "  <div class='bouton del_bouton' style='float:none;width:100%'><a class='annuler'>RETOUR À LA LISTE DES PRODUITS</a></div>\n";
    }
} else {
    header("location: admin.php?page=produits");
}

echo "</form>\n";
echo "</div>\n";
?>
Unkilling
  • 123
  • 1
  • 2
  • 7
0

To change the language that MySQL uses when reporting you need to change the my.ini file as follows

POST: WAMP/MySQL errors not in correct language

Community
  • 1
  • 1