Could not connect to mySql : Too many connections
Posted: Sat Sep 13, 2008 3:19 pm
hey guys, i keep getting this error,
Could not connect to mySql : Too many connections
whats the best way to fix it?
i only have connection to database once
and i am doing queries like this
what am i doing wrong guyes?
isit too many queries
Could not connect to mySql : Too many connections
whats the best way to fix it?
i only have connection to database once
Code: Select all
// Connect to database
$dbc = mysql_connect ('Localhost','username','password') OR die('Could not connect to mySql : ' . mysql_error());
mysql_select_db (databseName) OR die('Could not connect to mySql : ' . mysql_error());
Code: Select all
//----------------------------------------------------------------------//
// SQL query, to show all items
if ($action == '1') {
$query = "SELECT * FROM TblItems WHERE item = '$item'";
$result = mysql_query ($query);
Echo '<table style="width: 100%">';
$i=2;
echo '<tr>';
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
if ($row[netOption] == 1 && $row[qun] >= 1){
$imageToShow = '<a href="addItem.php?item=' . $row[id] . '" ><img alt="image of this product" src="images/buy.gif" BORDER=0 width="70" /></a>';
}
elseif ($row[netOption] == 0 && $row[qun] >= 1){
$imageToShow = '<img alt="only in store" src="images/buy2.gif" BORDER=0 width="70" />';
}
else {
$imageToShow = '<img alt="only in store" src="images/buy3.gif" BORDER=0 width="70" />';
}
if($i%2==0){
echo '</tr><tr>';
}
echo '<td>';
Echo '<table style="width: 100%">';
Echo '<tr><td><a href="images/' . $row[image] . '" target="-Blank"><img alt="image of this product" src="images/' . $row[image] .'" BORDER=0 width="70" /></a></td><td style="font-size: 0.9em"><a href="products.php?action=2&item=' . $row[item] . '&product=' . $row[id] . '">' . $row[name] . '</a><br>'. substr($row[dec], 0, 73) .'... <a href="products.php?item=' . $row[item] . '&product=' . $row[id] . '">more</a></td></tr>';
Echo '<tr><td></td><td align=Right><b>£' . $row[price] . '</b><br>' . $imageToShow . '</td></tr>';
Echo '</table><hr>';
echo '</td>';
$i++;
}
echo '</tr>';
Echo '</table>';
}
//----------------------------------------------------------------------//
// SQL query, to show a product
if ($action == '2') {
$query = "SELECT * FROM TblItems WHERE item = '$item' && id = '$product'";
$result = mysql_query ($query);
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
Echo '<font size="5" face="Algerian"><a href="products.php?item=' . $row[item] . '&product=' . $row[id] . '">' . $row[name] . '</a></font><br><br>';
Echo '<a href="images/' . $row[image] . '" target="-Blank"><img alt="image of this product" src="images/' . $row[image] .'" BORDER=0 width="300" /></a><br>';
Echo '<br>';
}
}
isit too many queries