<?php
$strServer = "db.Zip2Tax.com";
$strUsername = "z2t_sample";
$strDBPassword = "db_pwd";
$strDatabase = "zip2tax";
//Open the connection
$conn = @mssql_connect($strServer, $strUsername, $strDBPassword)
or die("Couldn't connect to SQL Server on $strServer");
//Open the Database
$d = @mssql_select_db($strDatabase, $conn)
or die("Couldn't open database $strDatabase");
//Set-up the Query
$query = mssql_init("z2t_lookup_Sample", $conn);
$strZipCode = "90210"; //sample zip code must be between 90001 and 92999
$strUserPassword = "user_pwd";
mssql_bind($query, "@zipcode", &$strZipCode, SQLVARCHAR);
mssql_bind($query, "@pwd", &$strUserPassword, SQLVARCHAR);
//Execute the query
$result = mssql_execute($query);
//Read the result
while($row = mssql_fetch_array($result))
{
echo "Zip Code: " . $row['Zip_Code'] . "<br>";
echo "Sales Tax Rate: " . $row['Sales_Tax_Rate'] . "<br>";
echo "Post Office City: " . $row['Post_Office_City'] . "<br>";
echo "County: " . $row['County'] . "<br>";
echo "State: " . $row['State'] . "<br>";
}
//Close the Database
mssql_close($conn);
?>