Entry
I need an example of PHP code using MSSQL database? I have installed PHP and MSSQL on my server.Both of them are working fine
Platform win2000Prof , MSSQL7.0, php4.2.2 , Apache WebServer and when I try to connect I have got me
Sep 8th, 2002 05:42
Pierre Koomen, narayanadas vakamudi, ilya osipov, www.php.net
<?php
$hostname = "localhost";
$username = "login";
$password = "password";
$dbName = "database";
MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO
RESPOND.");
mssql_select_db($dbName) or DIE("Table unavailable");
$query = "SELECT * FROM users";
$result = MSSQL_QUERY($query);
$number = MSSQL_NUM_ROWS($result);
$i=0;
if ($number == 0) :
print "No data?";
elseif ($number > 0) :
print "Data:
";
while ($i < $number) :
$name = mssql_result($result,$i,"Name");
print $name;
print "
";
$i++;
endwhile;
endif;
?>