johnh2009 Posted February 7, 2010 Share Posted February 7, 2010 Hey guys, im so sorry to plant this here, i was hoping to resolve this myself but im having problems with my self employed website. Been a while since i coded any php so ive been cannibalising old code i had from a few years ago, only now im getting this error: http://www.dotcomuk.co.uk/index1.php - which is Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home/fhlinux128/d/dotcomuk.co.uk/user/htdocs/_admin/oldb.php on line 6. The file that the info comes from looks as follows: <?php //function AvaaTietokanta ($osoite = "127.0.0.1",$tietokanta="igpc") function AvaaTietokanta ($osoite = "******",$tietokanta="*****") { // $yhteysnumero = mysql_connect($osoite,"root",""); $yhteysnumero = mysql_connect($osoite,"******","*****"); mysql_select_db($tietokanta); return $yhteysnumero; } // $id -muuttujan tarkistus // Mikäli $id on jotain muuta kuin numero, niin annetaan virheilmoitus // ja lopetetaan function cuttext($text,$num_characters) { $texto = htmlspecialchars($text); if (strlen($text) > $num_characters) { $text = substr($text, 0, $num_characters); # $text .= " ..."; } return $text; } function convert2proper($strVal){ $iPos = 0; $strValTmp = ""; do { $iSpace = strpos($strVal," ", $iPos); $strValTmp .= strtoupper(substr($strVal, $iPos, 1)); $strValTmp .= strtolower(substr($strVal, $iPos + 1, $iSpace - $iPos)); $iPos = $iSpace + 1; } while(strpos($strVal," ", $iPos) != FALSE); $strValTmp .= strtoupper(substr($strVal, $iPos, 1)); $strValTmp .= strtolower(substr($strVal, $iPos + 1)); return $strValTmp; } function cutString($strVal,$limit){ if(strlen($strVal)>$limit){ return substr($strVal,0,$limit) . "..."; }else{ return $strVal; } } ?> Also the code that is grabbing this is as follows: <?php require '_admin/oldb.php'; $yhteys = AvaaTietokanta();?> <?php if (!$kysely = mysql_query("select * FROM news order by id desc LIMIT 2",$yhteys)) { print "<LI>error on loading news!"; } else { while ($row = mysql_fetch_row($kysely)): $id = $row[0]; $texti = $row[2]; $shownews = cuttext($texti,200); $added=$row[3]; ?> <h2><?php echo "$row[1]"; ?></h2> <h4> » Added on <?php echo gmdate('l jS \of F Y',$added); ?> by <?php echo "$row[4]"; ?></h4> <p><?php print nl2br($shownews); ?>....<span class="orangeHighlight"><a href="fullnews.php?id=<?php echo "$id"; ?>">Read More</a></span></p><br> <?php endwhile; } ?> <h3>5 Most Recent News Items</h3> <?php $kyselyb = mysql_query("select * FROM news order by id desc LIMIT 5",$yhteys); while ($row = mysql_fetch_row($kyselyb)): $idb = $row[0]; $nextheadline = $row[1]; $nextheadline = cuttext($nextheadline,70); ?> <p>» <a href="fullnews.php?id=<?php echo "$idb"; ?>"><?php echo "$nextheadline"; ?></a></p> <?php endwhile; ?> <br> <p><a href="news-archive.php">Click Here for All Archived News Items</a></p> TBH im at a loss, ive tried googling but the pages that came up didnt make much sense to me at all. One site said to log into phpmyadmin and kill processes but when i try to log in i get the too many connections error there too. I dont know what to do Please help The original code was wrote by a Finnish friend of mine many years ago, so sorry about the weird wording on some of the code. Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/ Share on other sites More sharing options...
johnh2009 Posted February 7, 2010 Author Share Posted February 7, 2010 UPDATE: Ok it seems to have resolved itself....however im pretty sure ive got an eror in my coding for it to have happened in the first place so if anyone has any advice on how to avoid it i would be so grateful. This site is my livelyhood effectively and i suck majorly at coding, i based my site in tables because i have not got so far as to learn how to layout in css yet:( It is something ill update but after ive got one going. I am sorry im not a very high contributer but my knowledge is very limited and i fear id cause more issues that resolve right now. Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008340 Share on other sites More sharing options...
Mchl Posted February 7, 2010 Share Posted February 7, 2010 Too many connections... means your MySQL server was too busy for your script to connect to it. http://dev.mysql.com/doc/refman/5.1/en/too-many-connections.html Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008342 Share on other sites More sharing options...
johnh2009 Posted February 7, 2010 Author Share Posted February 7, 2010 i see, so is this an issue with my hosts server settings or me not closing mine? Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008345 Share on other sites More sharing options...
jl5501 Posted February 7, 2010 Share Posted February 7, 2010 Mchl, did the OP not say MSQL not MySQL? Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008347 Share on other sites More sharing options...
johnh2009 Posted February 7, 2010 Author Share Posted February 7, 2010 no it is MySQL i typo'ed MSQL tht is my fault sorry Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008349 Share on other sites More sharing options...
Mchl Posted February 7, 2010 Share Posted February 7, 2010 Mchl, did the OP not say MSQL not MySQL? That's why we ask for code Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008350 Share on other sites More sharing options...
Mchl Posted February 7, 2010 Share Posted February 7, 2010 i see, so is this an issue with my hosts server settings or me not closing mine? If your database is on shared server it might be that the load on the server was too high at this moment. PHP closes all connections automatically when script closes. Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008352 Share on other sites More sharing options...
johnh2009 Posted February 7, 2010 Author Share Posted February 7, 2010 yes it is hosted by an outside company, additionally i noticed that i couldnt log into my phpmyadmin CP also so what you said makes sense, thank you my mind is at ease once again Link to comment https://forums.phpfreaks.com/topic/191241-msql-connections/#findComment-1008359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.