Jump to content

[SOLVED] Connecting to MS SQL database


Yesideez

Recommended Posts

Anyone got any links to tutorials?

 

I've tried following the one on the MS website but there's no mention of selecting a user or password.

 

Bit stumped on this one!

 

This is the code so far...

  $serverName='(local)';
  $connectionOptions=array('Database'=>'database');
  $conn=sqlsrv_connect($serverName,$connectionOptions);
  if ($conn===false) {var_dump(sqlsrv_errors()); exit;}
  $query=$_REQUEST['query'];
  $tsql="SELECT * FROM dbo.Client LIMIT 10";
  $getProducts=sqlsrv_query($conn,$tsql,array($query));
  while ($row=sqlsrv_fetch_array($getProducts,SQLSRV_FETCH_ASSOC)) {
    foreach ($row as $key => $val) {
    	echo $key.'='.$val.'<br />';
    }
  }
  sqlsrv_close($conn);

Link to comment
https://forums.phpfreaks.com/topic/147744-solved-connecting-to-ms-sql-database/
Share on other sites

No thanks - but we've solved it.

 

Seems the Microsoft documentation is aimed at Microsoft technicians and not Joe Public.

 

Seems we had the database and server name the wrong way round even though the documentation showed it the wrong way :/

 

We can view all the records on the MS SQL server database within PHP using Microsoft's new driver.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

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.