ziedinjsh Posted April 5, 2010 Report Share Posted April 5, 2010 (edited) Man tāds jautājums.. ka es varu izdzēst informāciju no mysql? Šini gadījumā man ir links kuram ir jāizdzēš lietotāja avatars <a href='delete.php?avatar=delete&avatar=".$row['avatar']."' > delete.php $row = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE email = '{$_SESSION['email']}'")); if($_GET["avatar"]=="delete") { $avatar = $row['avatar']; $sql = sprintf("DELETE FROM users WHERE avatar = $avatar"); $result = mysql_query($sql); }else{ header("location: edit_profile.php"); } kapēc viņš neizdzēš?? Edited April 5, 2010 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted April 5, 2010 Report Share Posted April 5, 2010 Kādā jēgā tu tur izmanto sprintf? Tu zini ko tā funkcija vispār dara? Lai nu kā - galvenā vaina ir tur, ka DELETE kvērijā tev avatar lauka vērtība nav pēdiņās. (ja vien tas nav int) Pēcāk gan es jau paredzu jautājumu - kādēļ tas man izdzēš visu lietotāju, bet par to jau vēlāk. ^_^ Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted April 5, 2010 Author Report Share Posted April 5, 2010 labi un kā novērst to lai neizdzēš visu lietotāju? Quote Link to comment Share on other sites More sharing options...
chizijs Posted April 5, 2010 Report Share Posted April 5, 2010 (edited) mysql_query("UPDATE users SET avatars = '' WHERE id = '".$id."'"); Edited April 5, 2010 by chizijs Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted April 5, 2010 Author Report Share Posted April 5, 2010 nu man tagad ir šādi: <a href='delete.php?wath=avatar' > delete.php session_start(); include "misc/db.php"; $row = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE email = '{$_SESSION['email']}'")); if($_GET["wath"]=="avatar") { $id = $row['user_id']; mysql_query("UPDATE users SET avatar = '' WHERE id = '".$id."'"); }else{ header("location: edit_profile.php"); } uzspiežot uz linka atveras tukšā lapa un viss.. un bildi viņš neizdzēš! Quote Link to comment Share on other sites More sharing options...
chizijs Posted April 5, 2010 Report Share Posted April 5, 2010 un kur Tev $id ^^ es tev tikai, kā piemēru iedevu.. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted April 5, 2010 Author Report Share Posted April 5, 2010 (edited) ā, es sapratu kļūdu... WHERE id = '".$id."' vajadzēja WHERE user_id '".$id."' un kā es varētu unlink(); izmantot lai man izdzēš bildi no foldera? $avatar = $row['avatar'] $user_id = $row['user_id'] mysql_query("UPDATE users SET avatar = '' WHERE user_id = '".$user_id."'"); unlink("avatars/".$avatar); header("location: edit_profile.php"); Edited April 5, 2010 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.