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
https://forums.phpfreaks.com/topic/159349-solved-what-am-i-doing-wrong/
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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.