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 788 times)
« on: December 05, 2008, 09:46:16 AM »
Kailash Offline
Administrator
Newbie

View Profile WWW
*****

iTrader: 50
Posts: 276



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);
?>

Share this topic on AskShare this topic on BlinkbitsShare this topic on BlinklistShare this topic on BloglinesShare this topic on BmarksShare this topic on Del.icio.usShare this topic on DiggShare this topic on DzoneShare this topic on FacebookShare this topic on Feed Me LinksShare this topic on FurlShare this topic on GoogleShare this topic on LiveShare this topic on MagnoliaShare this topic on MySpaceShare this topic on NetvouzShare this topic on NewsvineShare this topic on OneviewShare this topic on RedditShare this topic on RojoShare this topic on ScuttleShare this topic on ShadowsShare this topic on SlashdotShare this topic on SpurlShare this topic on SquidooShare this topic on StumbleUponShare this topic on TechnoratiShare this topic on TwitterShare this topic on TipdShare this topic on YahooShare this topic on Google buzz
Logged

Pages: [1]   Go Up
Print
Jump to:  

Untitled Document
(c) 2010 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
Web Hosting - Sitemap - XML Sitemap