Jump to content

[SOLVED] what am I doing wrong??


justAnoob

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.