PHP Code:
 $sql "SELECT `propertyref` FROM `feed_property` WHERE `status` = 'Sold' OR `status` = 'Off Market' ";
$result $db->query($sql);

    if (isset(
        while (
$row $result->fetch_array(MYSQLI_ASSOC)):
$ref1 $db->real_escape_string($row['propertyref']);

$query1 "DELETE FROM `feed_property`, `feed_images`, `feed_characteristics`\n"
"USING `feed_property` INNER JOIN `feed_images` INNER JOIN `feed_characteristics`\n"
"WHERE feed_property.propertyref = '$ref1'\n"
" AND feed_images.propertyref = feed_property.propertyref\n"
" AND feed_characteristics.propertyref = feed_property.propertyref; ";

I cannot understand why the delete query works on my test server but not on my production server? On the latter it deletes the images and characteristics associated with an off market or Sold property, but it will not delete the property itself.

Any insight as to why this might be?