Jump to content

Problem with php mysql - please help if you can.


flemingmike

Recommended Posts

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]");



?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.