Jump to content

Warning: mysql_connect() [function.mysql-connect]: Too many connection


NealeWeb

Recommended Posts

Im making a site for my family to leave messages for everyone to see but every now and then the message wont load and i get theses errors,

 

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home/#####/public_html/#####.com/messages.php on line 17

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 18

 

Warning: mysql_query() [function.mysql-query]: Access denied for user '#####'@'localhost' (using password: NO) in /home/#####/public_html/#####.com/messages.php on line 21

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/#####/public_html/#####.com/messages.php on line 21

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 24

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/#####/public_html/#####.com/messages.php on line 25

 

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 54

 

 

i also recieved this error once

 

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

 

The hosting support team have been no help at all.

The code below is in a php file thats included (<?php include(messages.php); ?>) in a div thats refreshed every 5 mins using javascript.

 

<?php
$dbHost = "localhost";
$dbUser = "#####";
$dbPass = "#####";
$dbname = "#####";
$db = mysql_connect($dbHost,$dbUser,$dbPass);
mysql_select_db($dbname,$db);

mysql_query("UPDATE members SET active=NOW()
WHERE member_id = '$_SESSION[sESS_MEMBER_ID]'");

$requete = "SELECT * FROM public_messages ORDER BY id desc";
$result = mysql_query ($requete,$db);
while($row = mysql_fetch_array($result))
{
$msg = str_replace ("\r\n", '<br />', $row['message']);
$msg = str_ireplace($badwords,'<span class="censored">[Censored]</span>',$msg);
$author = $row['author'];
$dateandtime = $row['date_time'];
$mid = $row['msg_id'];
$aid = $row['auth_id'];
$cmnts = $row['comments'];
echo "<div class=\"msg_box\"><!--Start msg_box -->
            <img class=\"avatar\" src=\"users/$author/avatar.jpg\" />
            <span class=\"msgblue\">$author</span><br />
            <span class=\"msgdark\">$msg</span>
        <div class=\"msg_footer\">
            <div class=\"footer_left\">
                <span class=\"posted\">Posted: </span><span class=\"posted_date_time\">$dateandtime</span>
            </div>
            <div class=\"footer_right\">
                <a href=\"messagecomments.php?msgid=$mid\"><span class=\"msg_options\">Comments ($cmnts)</span></a>
                <img class=\"bubble\" src=\"images/speechbubble.png\" />";
                if ($_SESSION['SESS_MEMBER_ID'] == $aid) { echo "<a href=\"edit_message.php?msgid=$mid\" onclick=\"return confirm('You are about to edit this message.');\"><img class=\"edit\" src=\"images/edithover.png\" /></a><a href=\"deletemessage.php?msgid=$mid\" onclick=\"return confirm('You are about to delete this message.');\">
                <img class=\"delete\" src=\"images/deletehover.png\" /></a>";
                }
                else
                    { echo "<a href=\"reportmessage.php?msgid=$mid&activeuser=$activeuser\" onclick=\"return confirm('You are about to anonymously report this message as unsuitable.');\"><img class=\"report\" src=\"images/report.png\" /></a>"; }
                    echo "
            </div>
        </div></div><!--End msg_box -->";
} 
mysql_close($db);
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.