Jump to content

Warning: mysql_num_rows(): supplied argument is not a valid


smashmouth

Recommended Posts

Error I get:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 

Code that is being used to get this error:

 

<?
include 'login/dbc.php';
page_protect();
//Gets
$idbitch = $_SESSION['user_id'];
$boardid = $_GET['board_id'];
$whatact = $_GET['act'];
$view = $_GET['view_id'];
// Gather user and board info
$result = mysql_query("SELECT * FROM users WHERE id = $idbitch") or die(mysql_error());
$row = mysql_fetch_array( $result );

$resultboard = mysql_query("SELECT * FROM boards WHERE id = $boardid") or die(mysql_error());
$rowboard = mysql_fetch_array( $resultboard );

$username = $row['user_name'];
$title = $rowboard['title'];
$mod = $rowboard['owner'];
$descrip = $rowboard['description'];
$safetitle = str_replace("'", "", "$title"); 
$category = $rowboard['category'];
$symbol = $rowboard['symbol'];
$time = time();
//Check to see if board is favorite or not
$resultfav = mysql_query("SELECT * FROM favorites WHERE owner = '$username' AND boardid = '$boardid'") or die(mysql_error());
$rowfav = mysql_fetch_array( $resultfav );
$checkfav = $rowfav['boardid'];

//Add or remove board from favorites
if ($whatact == 1){
mysql_query("DELETE FROM favorites WHERE owner='$username' AND boardid = '$boardid'") 
or die(mysql_error());}
elseif ($whatact == 2) {
mysql_query("INSERT INTO favorites (owner, board, boardid, category, stock, lasttime) VALUES('$username', '".mysql_real_escape_string($title)."', '$boardid', '$category', '$symbol', '$time') ") 
or die(mysql_error());}
//Recheck to see if favorite has changed
$resultfav = mysql_query("SELECT * FROM favorites WHERE owner = '$username' AND boardid = '$boardid'") or die(mysql_error());
$rowfav = mysql_fetch_array( $resultfav );
$checkfav = $rowfav['boardid'];

//link variables
$link3 = "/viewuser.php?user_id=";
$linknext = "/viewboard.php?board_id=";
$replyto ="&msg_id=0";
$newmsg = "/newmsg.php?board_id=";
$viewboard = "&view_id=";
$viewfirst = "&view_id=0";
$removeact = "&act=1";
$addact = "&act=2";
//view next and previous code
$viewnext = $view + 50;
$viewprevious = $view - 50;

if ($checkfav > '0'){
mysql_query("UPDATE favorites SET lastcheck = '$time', unread = '0' WHERE boardid = '$boardid' AND owner = '$username'") 
or die(mysql_error());}
//SHORTEN TEXT CODE
/** 
* include "shorten_a_text_string.php"; 
* echo ShortenText($text); 
*/ 

    function ShortenText($text) { 

        // Change to the number of characters you want to display 
        $chars = 90; 

        $text = $text." "; 
        $text = substr($text,0,$chars); 
        $text = substr($text,0,strrpos($text,' ')); 
        $text = $text."..."; 

        return $text; 
} 

/** 
* include "shorten_a_text_string.php"; 
* echo ShortenText($text); 
*/ 

    function ShortenDescrip($text) { 

        // Change to the number of characters you want to display 
        $chars = 375; 

        $text = $text." "; 
        $text = substr($text,0,$chars); 
        $text = substr($text,0,strrpos($text,' ')); 
        $text = $text."..."; 

        return $text; 
} 
//check to see if there are previous 50 messages 
$resultcheck = mysql_query("SELECT id FROM messages WHERE board = '$boardid' AND viewable = '0' ORDER BY sortid DESC LIMIT 60 OFFSET $view"); 
$checkforprev = mysql_num_rows($resultcheck)


?>
<link REL="STYLESHEET" TYPE="text/css" HREF="/styles/master.css" Title="TOCStyle">
<style type="text/css">
<!--
.style9 {color: #FFFFFF}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The250Group</title>
<style type="text/css">
<!--
body {
background-color: #333333;
}
-->
</style>
</head>

<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top" bgcolor="#FFFFFF"><?php include('/home/investme/public_html/menu.php'); ?><script>document.getElementById('search').focus()</script></td>
  </tr>
  <tr>
    <td height="30" align="left" valign="middle" background="/img/border/5.jpg" bgcolor="#DFE6FF" class="style5"><table width="100%" border="0">
      <tr>
        <td width="429" align="left" valign="top"><span class="style4">
          <?php 
echo "<a href='".$linknext.$boardid.$viewfirst."'>".$title."</a>";?>
        </span></td>
        <td width="461" align="right" valign="middle" class="style8">Go to Post or Date 
          <input name="symbol" type="text" value="" size="8" /> <input name="submit" type="submit" value="Go" /></td>
      </tr>
    </table>    </td>
  </tr>
  <tr>
    <td height="50" align="left" valign="top" bgcolor="#FFFFFF" class="style5"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="30" align="left" valign="middle" bgcolor="#A7C6DC" class="style3"><span class="style8">Moderator: </span>
          <?php 
	echo "<a href='".$link3.$mod."'>".$mod."</a>";
	?> </td>
        <td height="25" align="left" valign="middle" bgcolor="#A7C6DC" class="style3">
	<?php if ($checkfav > 0){echo "<a href='".$linknext.$boardid.$viewfirst.$removeact."'>"."Remove Favorite"."</a>";}else {
	echo "<a href='".$linknext.$boardid.$viewfirst.$addact."'>"."Add Favorite"."</a>";}?>


	 </td>
      </tr>
      <tr>
        <td width="661" class="style10"><?php echo ShortenDescrip($descrip);?> </td>
        <td width="329" class="style10"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="250" height="25" align="left" valign="top"  bgcolor="#A7C6DC" class="style8"><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#A7C6DC">
      <tr>
        <td width="560" height="25" align="left" valign="middle"><table width="560" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td><?php echo "<td >" . "<a href='".$newmsg.$boardid.$replyto."'>"."Post a New Message"."</a>" . "</td>";?></td>
              <td> </td>
            </tr>
        </table></td>
        <td width="426" height="25" align="right" valign="middle"><table width="400" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td align="center" valign="bottom" class="style8"><?php if ($checkforprev > 50 ){echo "<td >" . "<a href='".$linknext.$boardid.$viewboard.$viewnext."'>"."Previous 50"."</a>" . "</td>";}else {echo "Previous 50";}?></td>
              <td align="center" valign="bottom" class="style8"><?php if ($view ==0){echo "<td align=\"center\">"."Next 50";}else {echo "<td >" . "<a href='".$linknext.$boardid.$viewboard.$viewprevious."'>"."Next 50"."</a>" . "</td>";}?></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top" background="/img/border/top.png" bgcolor="#FFFFFF" class="style5"><table width="1000" border="0" background="/img/border/top.png">
      <tr align="left" valign="middle" class="style1">
        <td width="75">Post #</td>
        <td width="625">Subject</td>
        <td width="150" align="center">Posted By </td>
        <td width="150" align="center">Time </td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top" bgcolor="#FFFFFF" class="style5"><?php
$result = mysql_query("SELECT * FROM messages WHERE board = '$boardid' AND sticky = '1' AND viewable = '0' ORDER BY sortid DESC LIMIT 10 OFFSET 0");

$link = "/viewmsg.php?msg_id=";
$link2 = "/viewuser.php?user_id=";
$msggetid = $row['id'];
echo "<table border='0' width='1000'cellpadding='0' cellspacing='0'>
<tr>

</tr>";

while($row = mysql_fetch_array($result))

  {

  echo "<tr bgcolor='#FFFF99'align=\"left\" valign=\"middle\">";
  echo "<td height='25'width=\"75\" align=\"center\">" . $row['sortid'] . "</td>";
  echo "<td height='25'width=\"625\">" . "<a href='".$link.$row['id']."'>".ShortenText($row['message'])."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"left\">" . "<a href='".$link2.$row['owner']."'>".$row['owner']."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"center\">" . $row['timemsg'] . "</td>";
  echo "</tr>";


  }
echo "</table>";

?>
      <br>
    <?php
$result = mysql_query("SELECT * FROM messages WHERE board = '$boardid' AND viewable = '0' ORDER BY sortid DESC LIMIT 50 OFFSET $view");
$color="1";
$link = "/viewmsg.php?msg_id=";
$link2 = "/viewuser.php?user_id=";
$msggetid = $row['id'];
echo "<table border='0' width='1000'cellpadding='0' cellspacing='0'>
<tr>

</tr>";

while($row = mysql_fetch_array($result))

  {
  if ($color ==1){
  echo "<tr bgcolor='#FFFFFF'align=\"left\" valign=\"middle\">";
  echo "<td height='25'width=\"75\" align=\"center\">" . $row['sortid'] . "</td>";
  echo "<td height='25'width=\"625\">" . "<a href='".$link.$row['id']."'>".ShortenText($row['message'])."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"left\">" . "<a href='".$link2.$row['owner']."'>".$row['owner']."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"center\">" . $row['timemsg'] . "</td>";
  echo "</tr>";
  $color="2";
  }
  else {
  
  echo "<tr bgcolor='#E0DFFD'align=\"left\" valign=\"middle\">";
  echo "<td height='25'width=\"75\" align=\"center\">" . $row['sortid'] . "</td>";
  echo "<td height='25'width=\"625\">" . "<a href='".$link.$row['id']."'>".ShortenText($row['message'])."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"left\">" . "<a href='".$link2.$row['owner']."'>".$row['owner']."</a>" . "</td>";
  echo "<td height='25'width=\"150\"align=\"center\">" . $row['timemsg'] . "</td>";
  echo "</tr>";
  $color="1";
  }
  }
echo "</table>";

?></td>
  </tr>
  
  <tr>
    <td width="250" height="25" align="left" valign="top" bgcolor="#A7C6DC" class="style8"><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#A7C6DC">
      <tr>
        <td width="560" height="25" align="left" valign="middle"><table width="560" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td><?php echo "<td >" . "<a href='".$newmsg.$boardid.$replyto."'>"."Post a New Message"."</a>" . "</td>";?></td>
              <td> </td>
            </tr>
        </table></td>
        <td width="426" height="25" align="right" valign="middle"><table width="400" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td align="center" valign="bottom" class="style8"><?php if ($checkforprev > 50 ){echo "<td >" . "<a href='".$linknext.$boardid.$viewboard.$viewnext."'>"."Previous 50"."</a>" . "</td>";}else {echo "Previous 50";}?></td>
              <td align="center" valign="bottom" class="style8"><?php if ($view ==0){echo "<td align=\"center\">"."Next 50";}else {echo "<td >" . "<a href='".$linknext.$boardid.$viewboard.$viewprevious."'>"."Next 50"."</a>" . "</td>";}?></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  
  
  <tr>
    <td height="50" align="left" valign="top" bgcolor="#DFE6FF"> </td>
  </tr>
  <tr>
    <td align="left" valign="top" bgcolor="#FFFFFF"><span class="style5">Phase 1: Initial develpment of site, get it up, working, and on the250group.com. <a href="/phases.php">Click here for a list of Phases. </a></span></td>
  </tr>
</table>
</body>
</html>

 

 

Any ideas on what I might be doing wrong? Thanks.

Archived

This topic is now archived and is closed to further replies.

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