troubleshooting Question

Retrieving values from MSSQL and display them in PHP

Avatar of CCC-Ravens
CCC-Ravens asked on
PHPMicrosoft SQL Server 2008
6 Comments1 Solution460 ViewsLast Modified:
I am trying to return data from a MSSql server and It seems to be connecting to the database ok but I am running into issues getting and displaying information here is the code I am trying to use keep in mind I have never used MSSQL I have always used MYSQL and so I may be way off base here.

$serverName = "myserver\myinstance"; //serverName\instanceName
$connectionInfo = array( "Database"=>"play", "UID"=>"user", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
	 $sqlquery = sqlsrv_query( $conn, $strsql);
      echo "Statement executed.\n";
	 while($row = sqlsrv_fetch_array($sqlquery)) {
      echo $row['Id_Num'];
      echo "Error in statement execution.\n";
      die( print_r( sqlsrv_errors(), true));

/* Free connection resources. */
sqlsrv_close( $conn);

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros