Hello,
In my code I am getting this error:
Warning: mysql_connect() [function.mysql-connect]: User turt2liv_demo already has more than 'max_user_connections' active connections in /home/turt2liv/public_html/demo/jamond_website/class.php on line 11
That method looks like this:
//Constructor
function __construct($debug){
if(!$debug){
$debug=0;
}
mysql_connect("localhost","turt2liv_demo","demoacc") or die("Connection Error: ".mysql_error());
mysql_select_db("turt2liv_demo_jamond_website") or die("Selection Error: ".mysql_error());
error_reporting($debug);
date_default_timezone_set("America/Edmonton");
if($this->isLoggedIn()){
setcookie("username",$_COOKIE['username'],time()+3600,"/");
}
}
and it only happens on the page that uses this code:
//Catalogue
public function catalogue($start,$search,$sort,$order){
if(!$start){
$start = 0;
}
$q = mysql_query("SELECT * FROM `items` WHERE `verified`='1'")or die(mysql_error());
$num = mysql_num_rows($q) or die(mysql_error());
echo "<p>Songs are priced based on the Admin's choice, keep in mind though, VIP Accounts can download right away for $10.00 a month. You are not aloud to download or buy without an account! Our sample audio player is brough to you by <a href='http://www.premiumbeat.com/flash_media_players/'>Premium Beat</a>.</p>";
echo "<p>To save music, right click the \"Download Now\" link and select \"Save Target As\" (or the equivlent of). This method does not work on \"Buy Now\" buttons. If you would like more information on a song, simply click it's name.</p>";
echo "<div style='background:#151515;width:700px;'>".$this->getSortOptions($search,$start)."</div>";
echo "<table border=0 style='width:700px;'>";
$searchDo = false;
if(isset($search)){
$search = " AND (name LIKE '%".$search."%' OR owner LIKE '%".$search."%') ";
$searchDo = true;
}else{
$search = " ";
}
if(isset($sort)){
if($sort == "mostrecent"){
$q = mysql_query("SELECT * FROM items WHERE verified='1'".$search."ORDER BY date $order LIMIT $start, 20")or die("ERROR 1: ".mysql_error());
}else if($sort == "topdownloaded"){
$q = mysql_query("SELECT * FROM items WHERE verified='1'".$search."ORDER BY hits $order LIMIT $start, 20")or die("ERROR 2: ".mysql_error());
}else if($sort == "artist"){
$q = mysql_query("SELECT * FROM items WHERE verified='1'".$search."ORDER BY owner $order LIMIT $start, 20")or die("ERROR 3: ".mysql_error());
}else if($sort == "song"){
$q = mysql_query("SELECT * FROM items WHERE verified='1'".$search."ORDER BY name $order LIMIT $start, 20")or die("ERROR 4: ".mysql_error());
}
}else{
$q = mysql_query("SELECT * FROM items WHERE verified='1'".$search."LIMIT ".$start.", 20;")or die("ERROR 5: ".mysql_error()."<br>"."SELECT * FROM items WHERE verified='1'".$search."LIMIT ".$start.", 20;");
}
if($searchDo){
$res = mysql_num_rows($q);
echo "<tr><td colspan=5 style='border-bottom:1px #6E6E6E solid;'><center><p>$res Results Found.</p></center></td></tr>";
}
echo "<tr><th style='border-bottom:1px #6E6E6E solid;'>Sample</th><th style='border-bottom:1px #6E6E6E solid;width:225px;'>Song Name</th><th style='border-bottom:1px #6E6E6E solid;width:125px;'></th><th style='border-bottom:1px #6E6E6E solid;width:225px;'>Artist</th><th style='border-bottom:1px #6E6E6E solid;width:125px;'>Buy Now</th></tr>";
if(mysql_num_rows($q) >= 1){
while($a = mysql_fetch_array($q)){
$id = $a['id'];
$name = $a['name'];
$artist = $a['owner'];
$sample = $a['samplePath'];
$path = $a['actualPath'];
$id = $a['id'];
if($this->isLoggedIn()){
if($this->isVIP()||$this->isServiceRep()){
$butt = "<a href='$path'>Download Now</a>";
}else{
$q2 = mysql_query("SELECT * FROM boughtItems WHERE email='$email' AND item='$id'");
if($a['owner_email']==$_COOKIE['username'] || mysql_num_rows($q2) == 1){
$butt = "<a href='$path'>Download Now</a>";
}else{
$butt = $this->purchaseButton($name,$a['cost']);
}
}
}else{
$butt = "Please Login First!";
}
echo "<tr><td style='border-bottom:1px #6E6E6E solid;'>".$this->audioPlayer($sample)."</td><td style='border-bottom:1px #6E6E6E solid;width:225px;'><a href='viewSong.php?id=$id'>$name</a></td><td style='border-bottom:1px #6E6E6E dashed;width:125px;'></td><td style='border-bottom:1px #6E6E6E solid;width:225px;'>$artist</td><td style='border-bottom:1px #6E6E6E solid;width:125px;'>$butt</td></tr>";
}
}else{
echo "<tr><td colspan=5 style='border-bottom:1px #6E6E6E solid;'><center><p>No Results! Sorry.</p></center></td></tr>";
}
echo "<tr><td colspan=5 style='border-bottom:1px #6E6E6E solid;'><center><p>".$this->getPages("cat.php",$start, $num)."</p></center></td></tr>";
echo "</table>";
}
Any help would be appreciated :)
EDIT:
Easier to read code here