flemingmike Posted February 24, 2009 Share Posted February 24, 2009 ie says error on line 44. here are the lines surrounding line 44. (it was working before, and just stopped. no changes to the script, only changes to database was more entries added. $totalteams=mysql_query("SELECT COUNT(*) FROM ladder_$id "); $totalteams=mysql_fetch_array($totalteams); $totalteams="$totalteams[0]"; here is my whole code: <? include("./includes/incglobal.php"); global $config; $groups=mysql_query("SELECT id,name,logo,active,priority,created FROM groups WHERE active='1' ORDER BY priority"); while(list($gid,$gname,$glogo,$gactive,$gpriority,$gcreated)=mysql_fetch_row($groups)){ $totalla=mysql_query("SELECT COUNT(*) FROM ladders WHERE grid='$gid' ORDER BY id"); $totalla=mysql_fetch_array($totalla); $totalla="$totalla[0]"; if(!$glogo){ $headlogo=""; }else{ $headlogo="<img src='$glogo' border='0'><br />"; } $out[body].="<center><br />$headlogo <table width='96%' cellpadding='1' cellspacing='1' bgcolor='#000000' border='0'> <tr> <td width='37%' style='background: url($config[bg]) repeat-x;' colspan='7'><b>$gname</b></td> </tr> <tr> <td width='37%' style='background: url($config[bg2]) repeat-x;'> Ladder</td> <td width='30%' style='background: url($config[bg2]) repeat-x;'> Game</td> <td width='8%' style='background: url($config[bg2]) repeat-x;'>Join</td> <td width='8%' style='background: url($config[bg2]) repeat-x;'>Rules</td> <td width='10%' style='background: url($config[bg2]) repeat-x;'>Matches</td> <td width='12%' style='background: url($config[bg2]) repeat-x;'>Count</td> <td width='3%' style='background: url($config[bg2]) repeat-x;'></td> </tr>"; if($totalla == 0){ $out[body].=" <tr bgcolor='$config[altcolora]'><td width='100%' background='$config[cellbg]' colspan='7'> There are currently no ladders in this group</td></tr>"; } $ladders=mysql_query("SELECT id,name,game,gamelink,grid,isteam,active FROM ladders WHERE grid='$gid' ORDER BY id"); while(list($id,$name,$game,$gamelink,$grid,$isteam,$active)=mysql_fetch_row($ladders)){ $totalteams=mysql_query("SELECT COUNT(*) FROM ladder_$id "); $totalteams=mysql_fetch_array($totalteams); $totalteams="$totalteams[0]"; if ($active == 0) { $light = "<img src='./images/ineligible.png' border='0' alt='Ladder is inactive!'>"; $link = "$name"; }else{ $light = "<img src='./images/eligible.png' border='0' alt'Ladder is active!'>"; $link = "<a href='$config[scripturl]/standings.php?ladder[id]=$id' class='content'>$name</a>"; } if($gamelink){ $glink="<a href='$gamelink'>$game</a>"; }else{ $glink="$game"; } if($config[altcolorx]==$config[altcolora]){ $config[altcolorx]="$config[altcolorb]"; }else{ $config[altcolorx]="$config[altcolora]"; } if($config[cellbgx]==$config[cellbg]){$config[cellbgx]="$config[cellbg2]";}else{$config[cellbgx]="$config[cellbg]";} $out[body].=" <tr bgcolor='$config[altcolorx]'> <td width='30%' background='$config[cellbgx]'> $link </td> <td width='30%' background='$config[cellbgx]'> $glink</td> <td width='8%' background='$config[cellbgx]'><a href='./join.php?ladder=$id'>Join!</a></td> <td width='8%' background='$config[cellbgx]'><a href='./rules.php?rules[ladderid]=$id'>Rules</a></td> <td width='10%' background='$config[cellbgx]'><a href='./matchdb.php?ladder=$id'>All Match</a></td> <td width='12%' background='$config[cellbgx]'>$totalteams</td> <td width='3%' background='$config[cellbgx]'>$light</td> </tr>"; } $out[body].="</table></center>"; } $out[body].="<br /><br />"; include("$config[html]"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/ Share on other sites More sharing options...
kenrbnsn Posted February 24, 2009 Share Posted February 24, 2009 And the error is??? We're not mind readers. Ken Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-770288 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 sorry... im an idiot... here is the error im recieving: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mash905/public_html/betting/ladders.php on line 44 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mash905/public_html/betting/ladders.php on line 44 Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-770986 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 2 items in your loop do not have an id set is what it seems like to me. Check your raw data in the database and make sure that the id column is populated properly. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771010 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 it appears the column might be called teamid? teamid name rank lrank wins loss games percent streak points kills king level strike_1 strike_2 strike_3 lastmatch 6 MaddenMike 0 0 0 0 0 0 0 0 0 1 [bLOB - 0 B] [bLOB - 0 B] [bLOB - 0 B] 0000-00-00 00:00:00 Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771028 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 So in your sql Query, change it to teamid, and that will hopefully solve your issue. Granted, MySQL probably returned an error as that column is probably not defined. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771030 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 so, i think im making some progress.... what i understand now is ladder_$id is representing the table (ie. ladder_345). what im trying to do is count the number of records inside that table. is this helping to give you any more idea of what im trying to accomplish? Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771037 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 so i tried to alter ladder_$id and it just killed the page... any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771053 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 is this helping to give you any more idea of what im trying to accomplish? I already know what you are trying to accomplish. The code more or less gives me that explanation. The issue is, you are getting mal data for that id, so the sql query is trying to pull "ladder_ " which in return is throwing a sql error cause $id was not set. $sql = "SELECT COUNT(*) FROM ladder_$id "; $totalteams=mysql_query($sql) or die("SQL: {$sql} <br />MySQL Returned:" . mysql_error()); Change that to be what I just posted and you will see the error given and it may help you diagnose the problem. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771055 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 ok, i changed the code, and this is the new error: SQL: SELECT COUNT(*) FROM ladder_166 MySQL Returned:Table 'mash905_betting.ladder_166' doesn't exist i checked for a table ladder_166 and it doesnt exist. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771063 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 ok, i changed the code, and this is the new error: SQL: SELECT COUNT(*) FROM ladder_166 MySQL Returned:Table 'mash905_betting.ladder_166' doesn't exist i checked for a table ladder_166 and it doesnt exist. That's your issue. Some of the id's are not valid ladder tables. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771070 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 so how can i eliminate this error? sorry... im new to this. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771071 Share on other sites More sharing options...
blintas Posted February 25, 2009 Share Posted February 25, 2009 You should query to grab a list of all the tables, then chop our the "ladder" portion using substr();, then get an array of all the IDs that are valid... Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771078 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 awesome info... but way over my head. i dont know... time to give up??? Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771082 Share on other sites More sharing options...
blintas Posted February 25, 2009 Share Posted February 25, 2009 Giving up is never the answer! Do a little bit of research on substr(); explode(); implode(); and mysql_fetch_assoc(); If you understand these functions, our solutions will work for you! Don't give up! Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771086 Share on other sites More sharing options...
flemingmike Posted February 25, 2009 Author Share Posted February 25, 2009 so i just created the table ladder_166, and no more error. all seems to be working. any chance this will happen again?? Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771104 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 so how can i eliminate this error? That is really a question for you to figure out. I do not know how these "ladder" tables are created. The issue is that when you add new data to the table you are getting $id from, you should create a new ladder table. I am not sure if that is the right logic, but that is how your logic works. That or have a column of ladderid in that table and use that to pull the right ladder table. Quote Link to comment https://forums.phpfreaks.com/topic/146719-problem-with-php-mysql-please-help-if-you-can/#findComment-771117 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.