Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2. $myServer = "x.x.x.x";
  3. $myUser = "xxx";
  4. $myPass = "xxxx";
  5. $myDB = "xxxx";
  6.  
  7. //connection to the database
  8. $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  9. or die("Couldn't connect to SQL Server on $myServer");
  10.  
  11. //select a database to work with
  12. $selected = mssql_select_db($myDB, $dbhandle)
  13. or die("Couldn't open database $myDB");
  14.  
  15. //declare the SQL statement that will query the database
  16. $query = "SELECT id, name, year ";
  17. $query .= "FROM cars ";
  18. $query .= "WHERE name='BMW'";
  19.  
  20. //execute the SQL query and return records
  21. $result = mssql_query($query);
  22.  
  23. $numRows = mssql_num_rows($result);
  24. echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
  25.  
  26. //display the results
  27. while($row = mssql_fetch_array($result))
  28. {
  29. echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
  30. }
  31. //close the connection
  32. mssql_close($dbhandle);
  33.  
  34. Fatal error: Call to undefined function mssql_connect() in C:xampphtdocsroshidmssqlphp.php on line 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement