NealeWeb Posted May 13, 2012 Share Posted May 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262477-warning-mysql_connect-functionmysql-connect-too-many-connection/ Share on other sites More sharing options...
litebearer Posted May 13, 2012 Share Posted May 13, 2012 It would help if you showed us messages.php Quote Link to comment https://forums.phpfreaks.com/topic/262477-warning-mysql_connect-functionmysql-connect-too-many-connection/#findComment-1345105 Share on other sites More sharing options...
Nyuszer Posted May 13, 2012 Share Posted May 13, 2012 Are you sure you typed the mysql login info correctly? Quote Link to comment https://forums.phpfreaks.com/topic/262477-warning-mysql_connect-functionmysql-connect-too-many-connection/#findComment-1345106 Share on other sites More sharing options...
NealeWeb Posted May 13, 2012 Author Share Posted May 13, 2012 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/262477-warning-mysql_connect-functionmysql-connect-too-many-connection/#findComment-1345108 Share on other sites More sharing options...
NealeWeb Posted May 13, 2012 Author Share Posted May 13, 2012 the connecct info is definatley ok as sometimes it works fine Quote Link to comment https://forums.phpfreaks.com/topic/262477-warning-mysql_connect-functionmysql-connect-too-many-connection/#findComment-1345110 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.