I am trying to unlink specified image which is linked with mysql table record ID.
I can delete the record on mysql. I get Internal server error when i run this script,
Query:
I have two cameras in_cam and out_cam folders I am trying a function swap lane where the images from in_cam copies to out_cam. my script copies the images from in_cam to out_cam but the image is not deleted in the in_cam.
Put the entry into the other table
$sql = "INSERT INTO $newCamTable (plate, nread, datetime, millisecs, nationality, image_name,image) SELECT plate, nread, datetime, millisecs, nationality, image_name,image FROM $camTable $
logit($sql);
$result = $conn->Execute($sql);
if (!$result)
{
print $conn->ErrorMsg();
}
$sql = "SELECT id FROM $newCamTable ORDER BY id DESC";
$result = $conn->Execute($sql);
if (!$result)
{
print $conn->ErrorMsg();
}
$row = $result->fields;
$newId = $row['id'];
$sql = "UPDATE $newCamTable SET name=\"$new_cam_name\", camera_id=\"$new_cam_id\" WHERE id=\"$newId\"";
logit($sql);
$result = $conn->Execute($sql);
if (!$result)
{
print $conn->ErrorMsg();
}
This is what I AM TRYING TO DO.
sql = """SELECT id FROM $camTable where id = \"$tableEntryId\" LIMIT 1";
logit($sql);
$result = $conn->Execute($sql);
$serverDir = $_SERVER['DOCUMENT_ROOT'];
$imagesTop = "/cam_images";
$idArray = str_split(strval($id));
$idString = implode('/', $idArray);
$webPath = $imagesTop . "/" . $camName . "/" . $idString . ".jpg";
$full_path = $serverDir . $webPath;
if (file_exists($full_path)) {
unlink($idString);
}*/
$sql = "DELETE FROM $camTable WHERE id=\"$tableEntryId\" LIMIT 1";
logit($sql);
$result = $conn->Execute($sql);
MYSQL RECORD
ID, camera_id, name, plate, nread, datetime, millisecs, nationlaity,image_name,image,checked
#
'542276', '38', 'HuddersfieldIN', 'YS63YPY', NULL, '2015-04-28 22:45:57', '648', 'GBR', 'YS63YPY-GBR_HuddersfieldIN_2015-04-28_22-45-57-648_UNKNOWN.jpg', ?, '0'
Image location - id String
/var/www/cam_images/HuddersfieldIN_anpr_vega/5/4/2/2/7/6.jpg
I am struggling hard to delete the image I don't know where am I going wrong.