mysql删除时出错

时间:2014-05-07 10:06:36

标签: mysql syntax sql-delete

我不明白为什么我有错误

  

“Erreur desyntaxeprèsde'1'àlaligne 1”

(抱歉,我是法国人......)

这是我的代码

$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);
}

然而,mysql删除工作正常但我的两个jpg仍然在这里由于错误。

2 个答案:

答案 0 :(得分:0)

致Zafar Malik:是的,选择工作正常

这是完整的代码

<?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";
?>

答案 1 :(得分:0)

要更改MySQL在报告时使用的语言,您需要更改my.ini文件,如下所示

  

POST:   WAMP/MySQL errors not in correct language

相关问题