require_once(ABSPATH . 'wp-config.php');

$formName = 'Trefbal Mania 15 april 2013';
$fieldName = 'logo';

$connectionString = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;

$database = new PDO($connectionString, DB_USER, DB_PASSWORD);

$sql = "SELECT field_value, file FROM wp_cf7dbplugin_submits WHERE form_name = '" . $formName . "' AND field_name = '" . $fieldName . "'";

$results = $database->query($sql);

foreach ($results as $result) {
	$counter++;

	$fileType = explode('.', $result['field_value']);
	$fileType ...