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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.