# HG changeset patch # User Matti Hamalainen # Date 1422357224 -7200 # Node ID 30bb894cfb5834be2a8103f471900883ec33ae83 # Parent 9858b93387a2a0d33e81a7af47a840e7a9640dcf Updated a bit. diff -r 9858b93387a2 -r 30bb894cfb58 urlredirect.php.txt --- a/urlredirect.php.txt Tue Jan 27 08:44:15 2015 +0200 +++ b/urlredirect.php.txt Tue Jan 27 13:13:44 2015 +0200 @@ -1,7 +1,7 @@ getMessage()."."); +} + // ========================================================== // Helper functions @@ -71,14 +81,7 @@ myerr("Invalid ID."); -// Find the URL -try { - $db = new PDO("sqlite:".$dbFilename); -} -catch (PDOException $e) { - myerr("Could not connect to URL database: ".$e->getMessage()."."); -} - +// Find the matching URL, if any foreach ($db->query("SELECT url FROM urls WHERE id=".$urlID) as $row) { header("Location: ".$row["url"]);