Created
February 4, 2014 12:44
-
-
Save kayalshri/8802958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbsetup.ini | |
========== | |
[dev] | |
DB_SERVER = "servername:port" | |
DB_NAME = "dbname" | |
DB_USER = "username" | |
DB_PASSWORD = "xxxxxxxxxxx" | |
[prod] | |
DB_SERVER = "servername:port" | |
DB_NAME = "prod_dbname" | |
DB_USER = "username" | |
DB_PASSWORD = "xxxxxxxxxxx" | |
connect.php | |
=========== | |
$user = "dev"; | |
$ini_array = parse_ini_file("dbsetup.ini", true); | |
$dbhandle = @mssql_connect($ini_array[$user]['DB_SERVER'],$ini_array[$user]['DB_USER'],$ini_array[$user]['DB_PASSWORD']) or die("Connection problem."); | |
$selected = @mssql_select_db($dbname[$dbid], $dbhandle); | |
$qry = "sp_spaceused syslogs"; | |
renderTable($qry); | |
function renderTable($qry){ | |
$result = @mssql_query($qry) or die(mssql_get_last_message()); | |
$k=0; | |
do{ | |
$numRows = mssql_num_rows($result); | |
$numCols= mssql_num_fields($result); | |
if($numCols){ | |
$k++; | |
echo "<h4>Result set[$k]:</h4><table width=100%>"; | |
print "<tr>"; | |
for ($i = 0; $i < mssql_num_fields($result); ++$i) { | |
echo "<th>".mssql_field_name($result, $i)."</th>"; | |
} | |
print "</tr>"; | |
while($row = mssql_fetch_array($result)){ | |
print "<tr>"; | |
# print_r($row); | |
$i++; | |
for ($j=0;$j<$numCols;$j++){ | |
print "<td>".$row[$j]."</td>"; | |
} | |
print "</tr>"; | |
} | |
print "<table><br>"; | |
} | |
}while (mssql_next_result($result)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment