<form name="form" action="verify.php" method="get">
<span class="style3"><span class="style10">.........</span>Enter Card Number:</span>
<input name="d" type="text" size="20" />
<input type="submit" name="submit" value="Enter" />
</form>
<p> </p>
<p>
<?php
$myServer = "***.**.***.**";
$myUser = "*******";
$myPass = "*******";
$myDB = "InternetServices";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
mysql_select_db($myDB) or die(mysql_error());
$userQuery = $_GET['d'];// user will enter the area code in the form to find city, tele number
// $userQuery = "971"; // default u can set here and uncomment this line
//declare the SQL statement that will query the database
$query = "SELECT AMT, Card_No ";
$query .= "FROM [InternetCards] ";
$query .= "WHERE Card_No ='$userQuery'";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
if(0==$numRows)
{
//close connection to prev db
mssql_close($dbhandle);
//now connect to the other db:
$myServer2 = "***.**.***.**";
$myUser2 = "*******";
$myPass2 = "*******";
$myDB2 = "InternetServices";
//connection to the database
$dbhandle = mssql_connect($myServer2, $myUser2, $myPass2)
or die("Couldn't connect to SQL Server on $myServer2");
mysql_select_db($myDB2) or die(mysql_error());
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
}
if( $numRows > 0 )
{
while($row = mssql_fetch_array($result))
{
echo "<h4><center><li>" . "You have " . $row ["AMT"]*20 . " minutes left on your card. </h4></center></li>";
}
}
mssql_close($dbhandle);
?>
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59:





by: AielloJPosted on 2009-10-28 at 10:55:13ID: 25686185
GSIAdmin:
The code change is attached. If the first query doesn't return any rows, the handle is closed and a connection to the second database created inside the 'if' block. You will have to substitute the correct connection strings.
Sincerely,
AielloJ
Select allOpen in new window