Yesideez Posted March 3, 2009 Share Posted March 3, 2009 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 More sharing options...
Yesideez Posted March 3, 2009 Author Share Posted March 3, 2009 OK I've managed to set the username and password using UID and PWD keys in the array but I still can't connect to the database. Anyone played with this before? Link to comment https://forums.phpfreaks.com/topic/147744-solved-connecting-to-ms-sql-database/#findComment-775554 Share on other sites More sharing options...
trq Posted March 3, 2009 Share Posted March 3, 2009 You'll want to use the odbc extension. Link to comment https://forums.phpfreaks.com/topic/147744-solved-connecting-to-ms-sql-database/#findComment-775562 Share on other sites More sharing options...
Yesideez Posted March 3, 2009 Author Share Posted March 3, 2009 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 https://forums.phpfreaks.com/topic/147744-solved-connecting-to-ms-sql-database/#findComment-775590 Share on other sites More sharing options...
Yesideez Posted March 3, 2009 Author Share Posted March 3, 2009 Also seems MS SQL doesn't have LIMIT, query changed to: SELECT TOP 10 * FROM dbo.Client Link to comment https://forums.phpfreaks.com/topic/147744-solved-connecting-to-ms-sql-database/#findComment-775611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.