Jump to content
PHPOMY

PHP Not connecting to SQL Server

Recommended Posts

Windows 2012 R2 Web Farm

IIs 8.5

PHP 7.2

 

 

I am trying to create a logon page using PHP  create a database on my SQL 2014 server.

Installed the PHP SQL Server Drivers for PHP 7.2

<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'SQLC,1433';

// Connect to MSSQL
$link = mssql_connect($server, 'phpuser', 'xxxxxxxxxxxxxx');

if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}
?>

I get an HTTP 500 internal server error cant get past this one

Any thing else I can provide to help us fix this let me know

 

Thank you

 

Tom

Share this post


Link to post
Share on other sites

Benanamen

Thank you for the fast response

 

I saw that link yesterday and tried that code

 

<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'SQLC,1433';

// Connect to MSSQL
$link = mssql_connect($server, 'phpuser', 'xxxxxxxxxxx');

if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}
?>

Named it testconnection.php

HTTP 500 Internal Server Error.

 

Any ideas?

Thakn you

 

Tom

Share this post


Link to post
Share on other sites

Ok I see what you meant now.

I need to convert my mssql_connect to use PDO

I have not been able to find an example of the replacement for this?

 

you have a example of using PDO to connect to a SQL Server Database?

 

Share this post


Link to post
Share on other sites

Got it working now this can be marked as resolved

 

Thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.