Internal server error when programmatically updating about 100 nodes
Give your server more memory ;)


Better to use EntityFieldQuery (but this will not speed up your script ..)
You could replace the while loop with foreach (array_keys($result['node']) as $node_id)
In the worst case you'll need to limit the $result or $nids array to 10 or something .. and run the script several times, maybe in cron ?


Or run an update query (also possible without php)

$sql = "UPDATE node node LEFT JOIN content_type_event node_data_field_event_date ON node.vid = node_data_field_event_date.vid SET node.status = 0 FROM WHERE (DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_event_date.field_event_date_value, '%Y-%m-%dT%T'), SEC_TO_TIME(-25200)), '%Y-%m-%d') &gt;= '2014-09-10' AND DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_event_date.field_event_date_value, '%Y-%m-%dT%T'), SEC_TO_TIME(-25200)), '%Y-%m-%d') &lt;= '2015-09-10') AND (node.type in ('event'))";

mysql_query($sql);