Closed atta1234 closed 3 months ago
I'm assuming this is about Azure Web Service? If so, what's the container OS, Windows or Linux?
I'm assuming this is about Azure Web Service? If so, what's the container OS, Windows or Linux?
Hi yes i m using microst azure webapp linux,, php version 8.2 and im using laravel to connect to sql server,
I'm assuming this is about Azure Web Service? If so, what's the container OS, Windows or Linux?
your help will be much appriciated thanks
I'm not very familiar with Azure Web Apps, but I created one to test with and set the stack to PHP 8.2 as well. It looks like the PHP driver and ODBC Driver 17 for SQL Server it uses is already installed there. Can you SSH into it and check if those are installed already?
If not, can you check if ODBC driver is installed, by doing cat /etc/odbcinst.ini
?
I'm not very familiar with Azure Web Apps, but I created one to test with and set the stack to PHP 8.2 as well. It looks like the PHP driver and ODBC Driver 17 for SQL Server it uses is already installed there. Can you SSH into it and check if those are installed already?
If not, can you check if ODBC driver is installed, by doing
cat /etc/odbcinst.ini
?
Hi bro i just check the driver is installed and fine working,,,if i make coonection in test routes like this below
`<?php // PHP Data Objects(PDO) Sample Code: echo 'hi'; try { $conn = new PDO("sqlsrv:server = tcp:proivder.database.windows.net,1433; Database = my", "username", "password"); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO users (name, email, password,role) VALUES ('John', 'ad@example.com', '12345678','test')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
echo 'conection establish';
}
catch (PDOException $e) {
print("Error connecting to SQL Server.");
die(print_r($e));
}
// SQL Server Extension Sample Code: $connectionInfo = array("UID" => "atta", "pwd" => "user123!@#", "Database" => "useraccess", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0); $serverName = "tcp:proivder.database.windows.net,1433"; $conn = sqlsrv_connect($serverName, $connectionInfo); ?>
` but from the laravel .env setting it's not working,,, it show the below error
"message": "SQLSTATE[28000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'atta'. (Connection: sqlsrv, SQL: select count(*) as aggregate from [users] where [email] = atta@gmail.com)",
"exception": "Illuminate\\Database\\QueryException",
"file": "/home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 793,
"trace": [
{
"file": "/home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 753,
"function": "runQueryCallback",
"class": "Illuminate\\Database\\Connection",
"type": "->"
},
It seems like a laravel issue, rather than the PHP Driver, so it may be better to ask this on their forums. However I did find this, that may be the same issue: https://stackoverflow.com/questions/54124262/how-to-fix-illuminate-database-queryexception-sqlstatehy000-1044-access-de
Closed due to inactivity
How to install this on azur webapp in php 8.1