PHP: Duplicate/Blank values when Inserting image names into the DB
<p>I am currently storing in MySQL database image names for easier way to retrieve the actual images. I am having problems with  the php code I created that stores the names. Duplicate and blank insertions are being made into the DB without my permission. </p>

<p>Is there a way to avoid this issue of duplicate or blank values being inserted when the page refreshed?</p>

<p><img src="http://i.stack.imgur.com/8Trdq.jpg" alt="enter image description here"></p>

<pre><code>&lt;?
$images = explode(',', $_GET['i']);

$path = Configuration::getUploadUrlPath('medium', 'target');


if (is_array($images)) {
    try {
        $objDb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
        $objDb-&gt;exec('SET CHARACTER SET utf8');
    } catch (PDOException $e) {
        echo 'There was a problem';
    }

    $sql = "INSERT INTO `urlImage` (`image_name`) VALUES ";

    foreach ($images as $image) {
        $value[] = "('" . $image . "')"; // collect imagenames
    }

    $sql .= implode(',', $value) . ";"; //build query
    $objDb-&gt;query($sql);
}

?&gt;
</code></pre>
