Display an error message when a query failed (previous : silent fail...)

This commit is contained in:
Gregory Soutade 2015-09-05 09:21:45 +02:00
parent b330af258f
commit b255a8cd90

View File

@ -169,14 +169,21 @@ function add_entry($user, $login, $password,
$result = $db->query("INSERT INTO gpass ('login', 'password', 'shadow_login', 'salt', 'access_token') VALUES
('" . $login . "', '" . $password . "', '" . $shadow_login . "', '" . $salt . "', '" . $access_token . "')");
error_log("INSERT INTO gpass ('login', 'password', 'shadow_login', 'salt', 'access_token') VALUES
('" . $login . "', '" . $password . "', '" . $shadow_login . "', '" . $salt . "', '" . $access_token . "')");
/* error_log("INSERT INTO gpass ('login', 'password', 'shadow_login', 'salt', 'access_token') VALUES */
/* ('" . $login . "', '" . $password . "', '" . $shadow_login . "', '" . $salt . "', '" . $access_token . "')"); */
$db->close();
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
}
function delete_entry($user, $login, $access_token)
{
@ -197,12 +204,21 @@ function delete_entry($user, $login, $access_token)
}
else
{
$db->query("DELETE FROM gpass WHERE login='" . $login . "'");
$result = $db->query("DELETE FROM gpass WHERE login='" . $login . "'");
$db->close();
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
}
}
function update_entry($user, $mkey, $old_login, $url, $login, $password, $shadow_login, $salt, $old_access_token, $new_access_token)
{
@ -257,7 +273,7 @@ function get_secure_entries($user, $access_tokens)
}
$query .= ")";
error_log($query);
//error_log($query);
$result = $db->query($query);
header('Content-Type: application/json');