Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Can not connect to SQL-Server with PHP

$
0
0

Hello Forum,

I'm just beginning with PHP-SQL programming so sorry if I ask some stupid questions...

I need help with connecting to SQL-Server 2012, by using php.
In Management Studio I have built a new Database by clicking on right mousebutton and selecting "new database".
So far, ok, I could add Tables and everything seems to be fine.

Now I tried to connect to this database from the local webserver (SQLServer and IIS on same virtual machine), using this code:

ini_set('display_errors', 1);
//phpinfo();

$server = '(local)'; //Alternatively I tried the Name of the Machine, which is the Name of SQL-Server
$connectioninfo = array('Database'=>'MyDatabase');
$dbconnection = sqlsrv_connect($server, $connectioninfo);

if ($dbconnection){
	echo "Connection established.<br />";
	}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

This results in "Fehler bei der Anmeldung für den Benutzer 'NT AUTHORITY\IUSR'" which means "Could not connect user 'NT AUTHORITY\IUSR".

So I tried to use additional 'UID'=>'MyDatabaseUser' and after failure I tried 'UID'=>'MyDatabaseUser' and 'PWD'=>'MyPassword'

So now I'm totally confused.
Did I add the Database the wrong way?
Did I add the User the wrong way?

Could someone please try to help me???

Thanks,

best regards Carsten


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>