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,13 +169,20 @@ 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();
echo "OK";
return true;
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
}
function delete_entry($user, $login, $access_token)
@ -197,10 +204,19 @@ 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();
echo "OK";
return true;
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
}
}
@ -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');