Exception handling for INSERT
This commit is contained in:
parent
73c1957129
commit
d1f0b54ff5
|
@ -62,11 +62,13 @@ function generate_short($url, $dbh) {
|
|||
$sth->execute();
|
||||
$loop++;
|
||||
}
|
||||
try {
|
||||
$sth = $dbh->prepare("INSERT INTO " . DB_TABLE . " (id, url, ip, count) VALUES (?, ?, ?, '0')");
|
||||
$sth->bindParam(1, $hash, PDO::PARAM_STR, HASH_LENGTH);
|
||||
$sth->bindParam(2, $url, PDO::PARAM_STR);
|
||||
$sth->bindParam(3, $clientip, PDO::PARAM_STR, 255);
|
||||
if (!$sth->execute()) {
|
||||
$sth->execute();
|
||||
} catch (PDOException $e) {
|
||||
$hash = "ERROR<br />Failed to insert hash!";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue