$row = $statement->fetch(PDO::FETCH_ASSOC); $shortUrl = _SITE_URL . $shortCode . DBUtils::toUId($row["id"], _BASE_MULTIPLIER); if (isset($_REQUEST['redirect']) && $_REQUEST['redirect'] == 1) { header('Location: ' . $shortUrl); } else { echo $shortUrl; } return; } $query = "INSERT INTO `items` (type, name, artist, album, image" . $insertQueryColumns . ", date) "; $query .= "VALUES(" . $itemType . ", :name, :artist, :album, :image"; $query .= $insertQueryValues . ", NOW())"; $statement = $db->prepare($query); $statement->bindParam(':name', $name, PDO::PARAM_STR); $statement->bindParam(':artist', $artist, PDO::PARAM_STR); $statement->bindParam(':album', $album, PDO::PARAM_STR); $statement->bindParam(':image', $image, PDO::PARAM_STR); // Executes the query $exe = $statement->execute(); $id = $db->lastInsertId(); if (!$exe || $exe == false || !$id || $id == 0) { // If we fail ... echo _SITE_URL . "/woops"; } else { $shortUrl = _SITE_URL . $shortCode . DBUtils::toUId($id, _BASE_MULTIPLIER); if (isset($_REQUEST['redirect']) && $_REQUEST['redirect'] == 1) { header('Location: ' . $shortUrl); } else { echo $shortUrl; } }