currently im working for a "fun" project and im stuck at a point. I created a MSSQL Server 2016 on Windows Server 2016 R2 and added a database and also some tabels. Now i want to select data from my database with PHP and there via PDO. But i wont get any output with my selections. I always end up in the "Sorry, we are missing your account!" part...
Note: The connection is working and i also can use INSERT INTO and UPDATE and so on.
Here is my PHP Script:
<?php
try {
$conn = new PDO("sqlsrv:Server=(local);Database=SomeDatabase", "SomeUser", "SomePassword");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$user = explode('\\', strtolower($_SERVER['AUTH_USER'])); //Split AUTH_USER into domain and username String
/*Check if user in Database*/
$sql = "SELECT * FROM account WHERE domain=:dom AND username=:user;";
$preparedQuery = $conn->prepare($sql);
if(!$preparedQuery->execute([':dom' => $user[0], ':user' => $user[1]])){
die('There was an error running the query.');
}
if ($preparedQuery->rowCount() == 1) {
echo "Willkommen, ".$user[1];
} else {
echo "Sorry, we are missing your account!<BR>Please contact our administrator.";
}
} catch(Exception $e) {
die(print_r($e->getMessage()));
}
?>
Here is my Profiler Output if i call the Script: http://i.epvpimg.com/WYfCeab.png
Always my rowCount() gives me -1 as output but thats not true... It also isnt working when i try "SELECT * FROM account;" with no parms... (Also i changed == 1 to >= 1 when i was trying the SELECT *)
Does anybody know why i wont be abel to get some outputs? Because the connection is working and i can use querys like INSERT. (The user also got the permissions for the select, i already checked it)