peet1909 Posted August 29, 2008 Share Posted August 29, 2008 When I try to display records from my MS SQL database, it doesn't show anyting (or errors for that matter). When I use different connection methods like DSN or ADODB connection it works fine. Why doesn't my code below work? <?php $myServer = "localhost"; $myUser = "your_name"; $myPass = "your_password"; $myDB = "examples"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //declare the SQL statement that will query the database $query = "SELECT id, name, year "; $query .= "FROM cars "; $query .= "WHERE name='BMW'"; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; //display the results while($row = mssql_fetch_array($result)) { echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>"; } //close the connection mssql_close($dbhandle); ?> Quote Link to comment https://forums.phpfreaks.com/topic/121839-problem-displaying-records-from-ms-sql-table/ Share on other sites More sharing options...
plimpton Posted September 8, 2008 Share Posted September 8, 2008 You can try to use the new sqlsrv driver created by microsoft and get support from them: http://blogs.msdn.com/sqlphp/ Quote Link to comment https://forums.phpfreaks.com/topic/121839-problem-displaying-records-from-ms-sql-table/#findComment-636766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.