Bloodfist
09-22-2002, 05:31 PM
Alright, I think this should be pretty easy for you PHP gurus. On my forum, I have the Karma hack installed.
The problem is guests. All I need to know is how to alter this code to not display error messages like this at the top of the page where a thread contains posts from guests:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 182
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 186
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 197
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 200
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 226
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 182
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 186
This is this code in admin/functions.php
//Karma
$gettotalpoint=mysql_query("SELECT newthread, reply, view, admin_mod, morereply, totalpenalty, date, redeem_points from storepoint where uid=$post[userid]");
$numrows_gettotal = mysql_num_rows($gettotalpoint);
if ($numrows_gettotal > '0' || $numrows_gettotal != '0' || $numrows_gettotal != '')
{
list ($newthread, $reply, $view, $admin_mod, $morereply, $totalpenalty, $date, $redeem_points) = mysql_fetch_row($gettotalpoint);
}
$gettotalpoint1=mysql_query("SELECT agreepoint, dispoint, imaword from point");
$numrows_gettotal1 = mysql_num_rows($gettotalpoint1);
if ($numrows_gettotal1 > 0)
{
list ($agreepoint, $dispoint, $imaword) = mysql_fetch_row($gettotalpoint1);
}
$getagree=mysql_query("SELECT * from adis where post_userid=$post[userid] and adis='a'");
$numrows_getagree = mysql_num_rows($getagree);
$getdis=mysql_query("SELECT * from adis where post_userid=$post[userid] and adis='d'");
$numrows_getdis = mysql_num_rows($getdis);
$adisagree = ($agreepoint) * ($numrows_getagree);
$adisdis = ($dispoint) * ($numrows_getdis);
$newadis = ($adisagree) + ($adisdis);
$post[totalpoint] = (($newthread) + ($reply) + ($view) + ($admin_mod) + ($morereply) + ($newadis)) - ($redeem_points);
$possible_total = ($newthread) + ($reply) + ($view) + ($admin_mod) + ($morereply) + ($newadis) + ($redeem_points);
if ($possible_total == '0')
{
$coverage = "0";
$coverage = $coverage . '%';
$post[totalpoint] = "0";
$possible_total = "0";
}
else
{
$coverage = ($post[totalpoint]/$possible_total) * 100;
$coverage = $coverage . '%';
}
//Checking Karma
if ($bbuserinfo[userid] != $post[userid])
{
$getkarma = mysql_query("SELECT * FROM adis WHERE userid = $bbuserinfo[userid] AND post_userid = $post[userid] AND postid = $post[postid]");
$resultkarma = mysql_num_rows($getkarma);
if ($resultkarma == 0)
{
$post[flag] = 0;
}
else
{
$post[flag] = 1;
}
}
//choose image/word/progress bar
if ($imaword == '0')
{
$check_posneg = substr($post[totalpoint], 0, 1);
if ($check_posneg != '-' && $post[totalpoint] != '0')
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kpos.gif\" border=\"0\" alt=\"Positive Karma\"></a><br>";
}
elseif ($check_posneg == '-')
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kneg.gif\" border=\"0\" alt=\"Negative Karma\"></a><br>";
}
else
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kbalance.gif\" border=\"0\" alt=\"Balance Karma\"></a><br>";
}
}
elseif ($imaword == '1')
{
$post[imaword] = "<smallfont>$post[totalpoint]</smallfont><br>";
}
elseif ($imaword == '2')
{
$post[table] = "<TABLE border=1 cellPadding=0 cellSpacing=0 style=\"BORDER-BOTTOM: #104a7b 1px solid; BORDER-LEFT: #104a7b 1px solid; BORDER-RIGHT: #104a7b 1px solid; BORDER-TOP: #104a7b 1px solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 1px\" width=\"60%\" height=\"10\"><tr>";
if ($post[totalpoint] == '0' && $possible_total == '0')
{
$post[td] = "<td width=100% bgcolor='white'></td>";
}
elseif ($redeem_points == '0' && $post[totalpoint] != '0')
{
$post[td] = "<td width=100% bgcolor='blue'></td>";
}
elseif ($post[totalpoint] != '0' && $possible_total != '0')
{
$post[td] = "<td width='$coverage' bgcolor='blue'></td>";
}
$post[td1] = "<td bgcolor='white'></td></tr></table>";
$post[over] = "<smallfont><b>" . $post[totalpoint] . "/" . $possible_total . "</b></smallfont>";
$post[imaword] = $post[table] . $post[td] . $post[td1] . $post[over];
}
Any help would be appriciated. Thanks.
The problem is guests. All I need to know is how to alter this code to not display error messages like this at the top of the page where a thread contains posts from guests:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 182
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 186
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 197
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 200
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 226
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 182
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/worldof/public_html/forums/admin/functions.php on line 186
This is this code in admin/functions.php
//Karma
$gettotalpoint=mysql_query("SELECT newthread, reply, view, admin_mod, morereply, totalpenalty, date, redeem_points from storepoint where uid=$post[userid]");
$numrows_gettotal = mysql_num_rows($gettotalpoint);
if ($numrows_gettotal > '0' || $numrows_gettotal != '0' || $numrows_gettotal != '')
{
list ($newthread, $reply, $view, $admin_mod, $morereply, $totalpenalty, $date, $redeem_points) = mysql_fetch_row($gettotalpoint);
}
$gettotalpoint1=mysql_query("SELECT agreepoint, dispoint, imaword from point");
$numrows_gettotal1 = mysql_num_rows($gettotalpoint1);
if ($numrows_gettotal1 > 0)
{
list ($agreepoint, $dispoint, $imaword) = mysql_fetch_row($gettotalpoint1);
}
$getagree=mysql_query("SELECT * from adis where post_userid=$post[userid] and adis='a'");
$numrows_getagree = mysql_num_rows($getagree);
$getdis=mysql_query("SELECT * from adis where post_userid=$post[userid] and adis='d'");
$numrows_getdis = mysql_num_rows($getdis);
$adisagree = ($agreepoint) * ($numrows_getagree);
$adisdis = ($dispoint) * ($numrows_getdis);
$newadis = ($adisagree) + ($adisdis);
$post[totalpoint] = (($newthread) + ($reply) + ($view) + ($admin_mod) + ($morereply) + ($newadis)) - ($redeem_points);
$possible_total = ($newthread) + ($reply) + ($view) + ($admin_mod) + ($morereply) + ($newadis) + ($redeem_points);
if ($possible_total == '0')
{
$coverage = "0";
$coverage = $coverage . '%';
$post[totalpoint] = "0";
$possible_total = "0";
}
else
{
$coverage = ($post[totalpoint]/$possible_total) * 100;
$coverage = $coverage . '%';
}
//Checking Karma
if ($bbuserinfo[userid] != $post[userid])
{
$getkarma = mysql_query("SELECT * FROM adis WHERE userid = $bbuserinfo[userid] AND post_userid = $post[userid] AND postid = $post[postid]");
$resultkarma = mysql_num_rows($getkarma);
if ($resultkarma == 0)
{
$post[flag] = 0;
}
else
{
$post[flag] = 1;
}
}
//choose image/word/progress bar
if ($imaword == '0')
{
$check_posneg = substr($post[totalpoint], 0, 1);
if ($check_posneg != '-' && $post[totalpoint] != '0')
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kpos.gif\" border=\"0\" alt=\"Positive Karma\"></a><br>";
}
elseif ($check_posneg == '-')
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kneg.gif\" border=\"0\" alt=\"Negative Karma\"></a><br>";
}
else
{
$post[imaword] = "<a href=\"java script:void(0);\" onclick=\"java script:alert('".addslashes($post[username])." has a total of $post[totalpoint] karma points.');\"";
$post[imaword].=" onMouseOver=\"window.status='".addslashes($post[username])." has a total of $post[totalpoint] karma points.'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"https://vborg.vbsupport.ru/images/kbalance.gif\" border=\"0\" alt=\"Balance Karma\"></a><br>";
}
}
elseif ($imaword == '1')
{
$post[imaword] = "<smallfont>$post[totalpoint]</smallfont><br>";
}
elseif ($imaword == '2')
{
$post[table] = "<TABLE border=1 cellPadding=0 cellSpacing=0 style=\"BORDER-BOTTOM: #104a7b 1px solid; BORDER-LEFT: #104a7b 1px solid; BORDER-RIGHT: #104a7b 1px solid; BORDER-TOP: #104a7b 1px solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 1px\" width=\"60%\" height=\"10\"><tr>";
if ($post[totalpoint] == '0' && $possible_total == '0')
{
$post[td] = "<td width=100% bgcolor='white'></td>";
}
elseif ($redeem_points == '0' && $post[totalpoint] != '0')
{
$post[td] = "<td width=100% bgcolor='blue'></td>";
}
elseif ($post[totalpoint] != '0' && $possible_total != '0')
{
$post[td] = "<td width='$coverage' bgcolor='blue'></td>";
}
$post[td1] = "<td bgcolor='white'></td></tr></table>";
$post[over] = "<smallfont><b>" . $post[totalpoint] . "/" . $possible_total . "</b></smallfont>";
$post[imaword] = $post[table] . $post[td] . $post[td1] . $post[over];
}
Any help would be appriciated. Thanks.