Home   Help Login Register  
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Search
WooThemes - Quality Themes, Great Support
Pages: [1]   Go Down
Print
Topic: Sample PHP MSSQL connection script  (Read 509 times)
0 Members and 1 Guest are viewing this topic.
« on: December 05, 2008, 09:46:16 AM »
Kailash Offline
Administrator
Newbie

View Profile WWW
*****

iTrader: 50
Posts: 273



Code:
<?php
$Server 
"localhost";
$User "your_name";
$Pass "your_password";
$DB "examples";

//connection to the database
$dbconn mssql_connect($Server$User$Pass)
  or die(
"Couldn't connect to SQL Server on $Server");

//select a database to work with
$selected mssql_select_db($DB$dbconn)
  or die(
"Couldn't open database $myDB");

//declare the SQL statement that will query the database
$query "SELECT name from test ";

//execute the SQL query and return records
$result mssql_query($query);

$numRows mssql_num_rows($result);
echo 
"<h1>" &#46; $numRows &#46; " Row" &#46; ($numRows == 1 ? "" &#58; "s") &#46; " Returned </h1>";

//display the results
while($row mssql_fetch_array($result))
{
  echo 
"<br>" &#46; $row["name"&#93;;
}
//close the connection
mssql_close($dbconn);
?>
Logged

Pages: [1]   Go Up
Print
Jump to:  

(c) 2009 HELM, WHM, cPanel, ASP, .Net development, PHP, MySQL, MSSQL Server, SEO support forum
Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC | Forum style designed by PixelSlot
Sitemap - XML Sitemap