×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: userc865b
Added: Sep 13, 2017 9:44 AM
Modified: Sep 13, 2017 9:44 AM
Views: 10
Tags: php
connection to sql server
  1. <?php
  2. // Server in diesem Format: <computer>\<instance name> oder
  3. // <server>,<port>, falls nicht der Standardport verwendet wird
  4. $server = '(local)';
  5.  
  6. $connectInfo=array("Database"=>"myDatabase");
  7. // Mit MSSQL verbinden
  8. $link = sqlsrv_connect($server, $connectInfo);
  9.  
  10. /*
  11. if($link)
  12.         echo "Connection established <br />";
  13. else{  
  14.         echo "Connection could not be established <br />";
  15.         die (print_r(sqlsrv_errors(),true));
  16.   }    
  17.  
  18.  
  19. $sql = "insert into Table_1(test) values (8)";
  20.  
  21. $result = sqlsrv_query($link,$sql);
  22.  
  23.  
  24. if(!$result )
  25.         echo mssql_error();
  26. else
  27.         echo "inserted!";
  28. */
  29. ?>
  30.