I may be jumping to conclusions, but I don't think you understand the difference between the PHP code being executed on the server, and the javascript being executed on the client. The javascript and PHP in your code you have written is not going to execute in the order you might expect it to.
When you first load your .php file, this PHP is going to be executed FIRST by the server:
if (mssql_query ("some query...")) {
mssql_query ("some query 2...")
?> alert('Succes!'); <?php
}
else { ?> alert('Query Fail'); <?php }
Notice that the mssql_query() function is being run regardless of the action of the user on the frontend.
Once your PHP has finished executing and if the if statement above is true, the following javascript code will be served to the browser
if (confirm('Some Question')) {
alert(''Success!);
}
else {
alert('Fail');
}
Notice that your page has loaded in the browser, none of your PHP is able to be run.
You have to restructure your logic in order to achieve what you want. A quick solution for your case would be to have just 2 files. 1 file with the javascript asking the confirmation of the user, and if confirm() then use either AJAX or a straight redirect of the user to yourscript.php which contains the code for executing the mssql query.
Happy coding!