Forum Moderators: coopster
I have a page that displays DB records..on this php file is a delete this record link. the link passes a var.
I have 2 files in dir's which need deleting which are pathed from the record.
So basically i need to access the record and tell the db to delete it and then unlink the 2 files refered to within the db record...
TIA for any help.
I would assume you have the id of the row to work with in this process.
select path from table where id=$id
keep the path value somewhere and then fir off the delete
delete from table where id=$id
then if that doesn't return an error do the
unlink($path);
include_once('db.php');
$conn = db_connect();
$model = $HTTP_GET_VARS['model'];
$query = "select from cars where model = $model";
$result = mysql_query($query,$conn);
$upfiledir = $result['picture'];
$thumb = $result['thumb'];
unlink($upfiledir);
unlink($thumb);
Here's what I'd do in that case though ...
include_once('db.php');
$conn = db_connect();
$model = $_GET['model']; // Same as HTTP_GET_VARS
$query = "select from cars where model = $model";
$result = mysql_query($query,$conn);
$row = mysql_fetch_array($result);
$upfiledir = $row['picture'];
$thumb = $row['thumb'];
unlink($upfiledir);
unlink($thumb);
$model = $_GET['model']; // Same as HTTP_GET_VARS
$query = "select from cars where model = $model";
exit($query);
$result = mysql_query($query,$conn);
I'm guessing that it's a syntax error as you aren't selecting any fields for one thing, and I always surround strings and dates with quotations:
$query = "select * from cars where model = '$model'"; // <-- surround text strings with quotes!