justAnoob Posted May 23, 2009 Share Posted May 23, 2009 trying to delete the image path from mysql..... It deletes it from the server directory but it won't delete the path from mysql... <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; $id_gone = $_SESSION['move_id']; //id of image $image5 = $_SESSION['path_5']; //path to image unlink($image5); mysql_query("DELETE imgpath5 FROM abcxyz WHERE id = '$id_gone'"); echo "image deleted."; echo "$id_gone"; //both variables echo,, so I know there working. echo "$image5"; ?> I tried using different variables(the 2 above) after the WHERE in the query to make it work,, but nothing. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 23, 2009 Share Posted May 23, 2009 imgpath5 needs to be in the WHERE claus Quote Link to comment Share on other sites More sharing options...
RussellReal Posted May 23, 2009 Share Posted May 23, 2009 ace, it doesn't HAVE to be, if the id corresponds to the result in the database, then it should work regardless.. do this noob <?php session_start(); require('connection.php'); $id = $_SESSION['move_id']; print_r(mysql_fetch_assoc(mysql_query("SELECT * FROM `abcxyz` WHERE `id` = '{$id}'"))); ?> and tell me what you get Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 23, 2009 Author Share Posted May 23, 2009 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in something is wrong with the synyax in the print line yes,,, i changed to crazy looking single quotes to regular single quotes.. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 23, 2009 Share Posted May 23, 2009 <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; $id_gone = $_SESSION['move_id']; //id of image $image5 = $_SESSION['path_5']; //path to image unlink($image5); $result = mysql_query("DELETE FROM abcxyz WHERE id = '$id_gone'"); if ($result) echo "image deleted."; ?> OR <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; $id_gone = $_SESSION['move_id']; //id of image $image5 = $_SESSION['path_5']; //path to image unlink($image5); $result = mysql_query("UPDATE abcxyz SET imgpath5 = '' WHERE id = '$id_gone'"); if ($result) echo "image deleted."; ?> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 23, 2009 Author Share Posted May 23, 2009 I'll try using the UPDATE..... Quote Link to comment Share on other sites More sharing options...
RussellReal Posted May 23, 2009 Share Posted May 23, 2009 you are not connecting to your database, or the query returns nothing.. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 23, 2009 Author Share Posted May 23, 2009 I am including the connection.php which connects. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 23, 2009 Share Posted May 23, 2009 Let's test that. <?php //error_reporting(E_ALL); //ini_set('display_errors',1); session_start(); require 'connection.php'; $id_gone = $_SESSION['move_id']; //id of image $image5 = $_SESSION['path_5']; //path to image unlink($image5); $result = mysql_query("UPDATE abcxyz SET imgpath5 = '' WHERE id = '$id_gone'") or die(mysql_error()); if ($result) echo "image deleted."; ?> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 23, 2009 Author Share Posted May 23, 2009 Think I got it Ken2k7,, something similar to what you have just posted... Let you know in a while. 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.