I've been working on this for about a week (maybe a little bit more) and I've made sure that all my db connections are closed.
host called today and said that 7778 connections were open. Is there anything in my code that I'm missing to make sure thant the connections are close and ready to be used by the next visitor
<?
require ("/home/httpd/html/internetgossip.net/htdocs/inc/db_connect.php");
if (!($link = mysql_connect($dbserver, $dblogin, $dbpass))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
$the_first = "SELECT user_id FROM the_userinfo WHERE user_active='active' AND admin_active='active' ";
if (!($checkamount = mysql_db_query($db, $the_first ))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
$total_entry = mysql_num_rows($checkamount);
mysql_free_result($checkamount); // clear from memory
//$allusers = mysql_fetch_array($getuser);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>title</title>
<link rel="stylesheet" href=http://www.phpbuilder.com/board/archive/index.php/"/inc/bad_style.css" type="text/css">
</head>
<body bgcolor="#000000" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<?
//$imageID = is_numeric($id) ? (int)$id : count($arrImage)-1;
//$imageID = ($imageID > count($arrImage)) ? count($arrImage)-1 : $imageID;
//$imageID = ($imageID < 0) ? 0 : $imageID;
if (!(is_numeric($start)) || !($start%10 == 0) || ($start > $total_entry)) { $start=0; }
if (!($start)) {
$s = 0;
$the_query = "SELECT user_id, username, photo_url, website_title FROM the_userinfo WHERE user_active='active' AND admin_active='active' ORDER BY number_in DESC LIMIT 10";
} else {
$s = "$start";
$ten = $s + 10;
$the_query = "SELECT user_id, username, photo_url, website_title FROM the_userinfo WHERE user_active='active' AND admin_active='active' ORDER BY number_in DESC LIMIT $s,$ten ";
}
$e = ($s + 10);
if (!($getuser = mysql_db_query($db, $the_query ))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
?>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td colspan="11" bgcolor="#ffffff">
<img src=http://www.phpbuilder.com/board/archive/index.php/"/img/spacer.gif" width="1" height="1"></td>
</tr>
<? for ($j=0; $j < 2; $j++) { ?>
<tr>
<td width="1" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
<?
$i = 0;
$ii = $i + 5;
while ($i < $ii) {
$allusers = mysql_fetch_array($getuser);
$theid = $allusers["user_id"];
$thename = $allusers["username"];
$thephoto = $allusers["photo_url"];
$thetitle = $allusers["website_title"];
if (!($allusers)) { // if there are no more rows then show the following:
$theid = "4";
$thename = "Badassdick";
$thephoto = "http://www.thespy.org/bad_logo.gif";
$thetitle = "Badassdick";
}
?>
<td bgcolor="#000000">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td width="2" bgcolor="#000000">
<img src="/img/spacer.gif" width="2" height="1"></td>
<td width="80">
<a href="site_out.php?id=<?echo $theid;?>" target="_blank"><img src="<?echo $thephoto;?>" width="80" height="120" border="0" alt="<?echo $thetitle;?>"></a></td>
<td width="2" bgcolor="#000000">
<img src="/img/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td colspan="3" class="ranktext" align="center">
<a href="site_out.php?id=<?echo $theid; ?>" target="_blank"><?echo $thename;?></a><br></td>
</tr>
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
</table>
</td>
<td width="1" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
<?
$i++;
}
?>
</tr>
<tr>
<td colspan="11" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
</tr>
<?
}
?>
<tr>
<td colspan="11" align="left" bgcolor="#000000" class="ranktext" align="center">
<?
//$u = mysql_num_rows($getuser); // gets number of users / entries in TABLE the_userinfo
$p = ($total_entry / 10); // number of pages
$q = round($p); // rounds number.
//$q = "$q";
/*
$n=0;
while ($n <= $q) {
$nn = $n + 1;
$t = ($n*10);
echo("<a href=\"main.php?start=$t\">Page $nn</a> ");
$n++;
} */
for ($n=0; $n<$q; $n++) {
$nn = $n + 1;
$t = ($n*10);
echo("<a href=\"main.php?start=$t\">Page $nn</a> ");
}
//mysql_free_result($getuser); // clears $getuser
//mysql_close($link);
unset($link);
?>
</td>
</tr>
</table>
</body>
host called today and said that 7778 connections were open. Is there anything in my code that I'm missing to make sure thant the connections are close and ready to be used by the next visitor
<?
require ("/home/httpd/html/internetgossip.net/htdocs/inc/db_connect.php");
if (!($link = mysql_connect($dbserver, $dblogin, $dbpass))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
$the_first = "SELECT user_id FROM the_userinfo WHERE user_active='active' AND admin_active='active' ";
if (!($checkamount = mysql_db_query($db, $the_first ))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
$total_entry = mysql_num_rows($checkamount);
mysql_free_result($checkamount); // clear from memory
//$allusers = mysql_fetch_array($getuser);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>title</title>
<link rel="stylesheet" href=http://www.phpbuilder.com/board/archive/index.php/"/inc/bad_style.css" type="text/css">
</head>
<body bgcolor="#000000" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<?
//$imageID = is_numeric($id) ? (int)$id : count($arrImage)-1;
//$imageID = ($imageID > count($arrImage)) ? count($arrImage)-1 : $imageID;
//$imageID = ($imageID < 0) ? 0 : $imageID;
if (!(is_numeric($start)) || !($start%10 == 0) || ($start > $total_entry)) { $start=0; }
if (!($start)) {
$s = 0;
$the_query = "SELECT user_id, username, photo_url, website_title FROM the_userinfo WHERE user_active='active' AND admin_active='active' ORDER BY number_in DESC LIMIT 10";
} else {
$s = "$start";
$ten = $s + 10;
$the_query = "SELECT user_id, username, photo_url, website_title FROM the_userinfo WHERE user_active='active' AND admin_active='active' ORDER BY number_in DESC LIMIT $s,$ten ";
}
$e = ($s + 10);
if (!($getuser = mysql_db_query($db, $the_query ))) {
displayerrmsg(sprintf("Internal Error %d:%s\n", mysql_errno(), mysql_error()));
exit();
}
?>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td colspan="11" bgcolor="#ffffff">
<img src=http://www.phpbuilder.com/board/archive/index.php/"/img/spacer.gif" width="1" height="1"></td>
</tr>
<? for ($j=0; $j < 2; $j++) { ?>
<tr>
<td width="1" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
<?
$i = 0;
$ii = $i + 5;
while ($i < $ii) {
$allusers = mysql_fetch_array($getuser);
$theid = $allusers["user_id"];
$thename = $allusers["username"];
$thephoto = $allusers["photo_url"];
$thetitle = $allusers["website_title"];
if (!($allusers)) { // if there are no more rows then show the following:
$theid = "4";
$thename = "Badassdick";
$thephoto = "http://www.thespy.org/bad_logo.gif";
$thetitle = "Badassdick";
}
?>
<td bgcolor="#000000">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td width="2" bgcolor="#000000">
<img src="/img/spacer.gif" width="2" height="1"></td>
<td width="80">
<a href="site_out.php?id=<?echo $theid;?>" target="_blank"><img src="<?echo $thephoto;?>" width="80" height="120" border="0" alt="<?echo $thetitle;?>"></a></td>
<td width="2" bgcolor="#000000">
<img src="/img/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
<tr>
<td colspan="3" class="ranktext" align="center">
<a href="site_out.php?id=<?echo $theid; ?>" target="_blank"><?echo $thename;?></a><br></td>
</tr>
<tr>
<td colspan="3" bgcolor="#000000">
<img src="/img/spacer.gif" width="1" height="2"></td>
</tr>
</table>
</td>
<td width="1" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
<?
$i++;
}
?>
</tr>
<tr>
<td colspan="11" bgcolor="#ffffff">
<img src="/img/spacer.gif" width="1" height="1"></td>
</tr>
<?
}
?>
<tr>
<td colspan="11" align="left" bgcolor="#000000" class="ranktext" align="center">
<?
//$u = mysql_num_rows($getuser); // gets number of users / entries in TABLE the_userinfo
$p = ($total_entry / 10); // number of pages
$q = round($p); // rounds number.
//$q = "$q";
/*
$n=0;
while ($n <= $q) {
$nn = $n + 1;
$t = ($n*10);
echo("<a href=\"main.php?start=$t\">Page $nn</a> ");
$n++;
} */
for ($n=0; $n<$q; $n++) {
$nn = $n + 1;
$t = ($n*10);
echo("<a href=\"main.php?start=$t\">Page $nn</a> ");
}
//mysql_free_result($getuser); // clears $getuser
//mysql_close($link);
unset($link);
?>
</td>
</tr>
</table>
</body>