-1

How can connect my mssql dtabase to my website i am using this code:

<?php
$user= 'abhi'; 
$pass = '';
$db_conn = new PDO('mssql:host=localhost;dbname= Abhishek', $user, $pass);
?>
devpro
  • 16,184
  • 3
  • 27
  • 38
  • 1
    The dbname has a space just before the actual name, try finding out the [error message](https://stackoverflow.com/questions/3999850/pdo-error-message) – ka_lin Feb 21 '19 at 14:23

1 Answers1

0

I know it's not exactly what you're asking, but do you really want to connect manually to a database and create your own sql?, with all dangers and annoying coding with it?

If I were you I'd use something lightweight like Medoo - will save you a lot of time.

see https://medoo.in

<?php
require 'vendor/autoload.php';
use Medoo\Medoo;

$database = new Medoo([
    'database_type' => 'mssql',
    'database_name' => 'name',
    'server' => 'localhost',
    'username' => 'your_username',
    'password' => 'your_password'
]);

$result = $database->select("account", [
    "user_name",
    "email"
];
Nico
  • 559
  • 4
  • 22