Jump to content

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


sitesme

Recommended Posts

Hi,

 

After moving server my script started showing this error:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/public_html/blog.php on line 107

 

Here is the code on line 107:

if(mysql_num_rows($ExeqryComm)!=0){

 

Any help please?

 

Thank you all

Link to comment
Share on other sites

Sure, here it is:

$SelectqryComm="select * from ". COMMENT . " where commentid='$Menu' and varStatus='Active'   order by CommDate  limit $offset, $limit";
$ExeqryComm=mysql_query($SelectqryComm);
$BlogCommentsdis.='<table cellpadding="0" cellspacing="0" border="0">';
  		$i =0;
$BlogCommentsdis.=' <tr>
    <td>    <form action="" method="post" name="commentfrm"  onSubmit="return fn_comments();"><table width="79%" border="0" align="left" cellpadding="3" cellspacing="3" height="80px">';
	 if($statusemail=="suc") {
$BlogCommentsdis.='<tr>
					          <td colspan="2" align="center" class="informationbox" style="text-align:center">'.$varConfirmationOpiniao.'</td>
			            </tr>'; }
$BlogCommentsdis.='<tr>
					  <td width="51%" align="right"  style="text-align:right;" class="smalltxt">Nome <span class="error">*</span> </td>
					  <td width="49%" align="left"><input type="text" name="varName" class="txt" size="50"/></td>
					  </tr>
					  <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Email <span class="error">*</span></td>
					    <td align="left"><input type="text" name="varEmail" class="txt" size="50"/></td></tr>
						<!-- <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Data <span class="error">*</span></td>
					    <td align="left"><input name="varData" type="text"  class="txt"/></td>
					    </tr>-->
						 <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Localidade <span class="error">*</span></td>
					    <td align="left"><input name="varLocalidade" type="text"   class="txt"/></td>
					    </tr>
                    <tr valign="top">
            <td height="27" align="right" class="smalltxt">Comentário <span class="error">*</span></td>
            <td height="27" class="leftcontent"><textarea name="shortnews" cols="50" rows="6" class="inputbox1"></textarea></td>
	  </tr>
<tr valign="top"><td height="27" colspan="3" align="center"><input type="submit" name="post" id="post" value="Submeter" class="buttonsub"><input type="hidden" name="task" id="task" value="'.base64_encode($Menu).'"></td></tr>
                  </table>
</form>  </td>  </tr>
<tr>
    <td>    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">';
if(mysql_num_rows($ExeqryComm)!=0){

$BlogCommentsdis.='<tr>
                <td width="76%" class="pickheadcss">As opiniões</td>
              </tr>';
   while($FetchqryComm=mysql_fetch_array($ExeqryComm)) { $i++; 
  $CommDate_blog = dateformat($FetchqryComm['CommDate']);
  $Description_blog = $FetchqryComm['Description'];
  $bid = $FetchqryBlog['intblogid'];
  $varName_blog = $FetchqryComm['varName'];
   $varEmail_blog = $FetchqryComm['varEmail'];
			  
$BlogCommentsdis.='<tr>
                <td width="76%" class="picktext14">'.$varName_blog.'</td>
              </tr><tr>
                <td width="76%" class="new">'.$CommDate_blog.'</td>
              </tr>
		  <tr>
                <td width="76%" class="new"> </td>
              </tr>
                    <tr>
                      <td>'.$Description_blog.'</td>
                    </tr>
				<tr>
                      <td style="border-bottom:1px solid #ffa2b5;"> </td>
                    </tr>';
				 	} 
$BlogCommentsdis.='<tr>
                      <td><table width="65%"  border="0" align="center" cellpadding="3" cellspacing="3">
  <tr>
    <td width="97%" align="right">';
	if($limit < $total)
	{
			if ($page == 1)
			{
				echo ""; 
			}
			else 
			{       
				$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=" . ($page - 1) . "\" class='linksnew'>Prev</a>"; 
			}
			for ($i = 1; $i <= $pager->numPages; $i++) 
			{ 
				$BlogCommentsdis.=" | "; 
				if ($i == $pager->page)
				{ 
					$BlogCommentsdis.="<span class='Hint1'>"."$i"."</span>"; 
				}
				else
				{	 
					$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=$i\" class='linksnew'> $i</a>"."</font>"; 
				}
			} 

			if ($i > 1)
			{
			 $BlogCommentsdis.=" | "; 
			}
	  
			if ($page == $pager->numPages) 
			{
			$BlogCommentsdis.="";
			} 
			else   
			{     
				$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=" . ($page + 1) . "\" class='linksnew'>Next</a>";
			}
	}		

$BlogCommentsdis.='</td>
    <td width="3%" align="right"> </td>
  </tr>
</table></td>

 

Thanks

Link to comment
Share on other sites

If your code previously worked, the error (and if you searched for that error you would already know) means that your query failed due to an error either with the database server, your connection to the database server, or with your table/query.

 

For debugging purposes (remove it when you are done), to find out why your query failed, you can echo mysql_error() on the next line after the line with your mysql_query() statement.

Link to comment
Share on other sites

The transfer was made between servers and it shouldn't be any problem on both versions.

I believe it is a matter of configuration in PHP or MySQL.

 

I remember a similar problem that was fixed with some sort of "hide errors" on PHP configuration or somewhat?

 

Link to comment
Share on other sites

The transfer was made between servers and it shouldn't be any problem on both versions.

I believe it is a matter of configuration in PHP or MySQL.

 

I remember a similar problem that was fixed with some sort of "hide errors" on PHP configuration or somewhat?

 

I would recommend fixing the problem rather than just turning off error reporting

Link to comment
Share on other sites

And you're sure the transfer isn't the culprit? I usually see this error if the query failed and you don't realize it (I'm with PFMaBiSmAd...use mysql_error() ), you're using the wrong variable in the argument, or if the field type got switched in the db. Can you double check those things?

Link to comment
Share on other sites

As I don't want to damage the code, can you please tell me the exact line where I should add "echo mysql_error()"?

 

Thank you

 

 

$ExeqryComm=mysql_query($SelectqryComm) or die (mysql_error());

 

It should be added to all queries during testing stages

Link to comment
Share on other sites

It's telling you it doesn't like the $offset and $limit variables, but since you only showed us a portion of your code, we can't tell what's going on before line 20, (like are they being populated correctly). Try wrapping them in single quotes and see what happens

Link to comment
Share on other sites

I've changed from:

$SelectqryComm="select * from ". COMMENT . " where commentid='$Menu' and varStatus='Active' order by intid limit $offset, $limit";

to:

$SelectqryComm="select * from ". COMMENT . " where commentid='$Menu' and varStatus='Active' order by intid limit '$offset', '$limit'";

 

but the result is the same.

 

I removed the "limit $offset, $limit" part and the error is gone but then... I do not get pagination in the page...

 

 

The full page code is here:

// Display Event Details

$Q_Check	= "select * from ". COMMENT . " where commentid='$Menu' and varStatus='Active' order by CommDate";
$R_Check	= mysql_query($Q_Check) or die(mysql_error());
$C_Check	= mysql_num_rows($R_Check);
$total		= mysql_num_rows($R_Check);	

$page = $_GET['page']; 
$limit = $Fetch['intRows']; 
//$limit = 10; 

$pager  = getPagerData($total, $limit, $page); 
$offset = $pager->offset; 
$limit  = $pager->limit; 
$page   = $pager->page; 	

$SelectqryComm="select * from ". COMMENT . " where commentid='$Menu' and varStatus='Active'   order by CommDate  limit $offset, $limit";
$ExeqryComm=mysql_query($SelectqryComm);
$BlogCommentsdis.='<table cellpadding="0" cellspacing="0" border="0">';
  		$i =0;
$BlogCommentsdis.=' <tr>
    <td>    <form action="" method="post" name="commentfrm"  onSubmit="return fn_comments();"><table width="79%" border="0" align="left" cellpadding="3" cellspacing="3" height="80px">';
	 if($statusemail=="suc") {
$BlogCommentsdis.='<tr>
					          <td colspan="2" align="center" class="informationbox" style="text-align:center">'.$varConfirmationOpiniao.'</td>
			            </tr>'; }
$BlogCommentsdis.='<tr>
					  <td width="51%" align="right"  style="text-align:right;" class="smalltxt">Nome <span class="error">*</span> </td>
					  <td width="49%" align="left"><input type="text" name="varName" class="txt" size="50"/></td>
					  </tr>
					  <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Email <span class="error">*</span></td>
					    <td align="left"><input type="text" name="varEmail" class="txt" size="50"/></td></tr>
						<!-- <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Data <span class="error">*</span></td>
					    <td align="left"><input name="varData" type="text"  class="txt"/></td>
					    </tr>-->
						 <tr>
					    <td align="right" style="text-align:right;" class="smalltxt">Localidade <span class="error">*</span></td>
					    <td align="left"><input name="varLocalidade" type="text"   class="txt"/></td>
					    </tr>
                    <tr valign="top">
            <td height="27" align="right" class="smalltxt">Comentário <span class="error">*</span></td>
            <td height="27" class="leftcontent"><textarea name="shortnews" cols="50" rows="6" class="inputbox1"></textarea></td>
	  </tr>
<tr valign="top"><td height="27" colspan="3" align="center"><input type="submit" name="post" id="post" value="Submeter" class="buttonsub"><input type="hidden" name="task" id="task" value="'.base64_encode($Menu).'"></td></tr>
                  </table>
</form>  </td>  </tr>
<tr>
    <td>    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">';
if(mysql_num_rows($ExeqryComm)!=0){

$BlogCommentsdis.='<tr>
                <td width="76%" class="pickheadcss">As opiniões</td>
              </tr>';
   while($FetchqryComm=mysql_fetch_array($ExeqryComm)) { $i++; 
  $CommDate_blog = dateformat($FetchqryComm['CommDate']);
  $Description_blog = $FetchqryComm['Description'];
  $bid = $FetchqryBlog['intblogid'];
  $varName_blog = $FetchqryComm['varName'];
   $varEmail_blog = $FetchqryComm['varEmail'];
			  
$BlogCommentsdis.='<tr>
                <td width="76%" class="picktext14">'.$varName_blog.'</td>
              </tr><tr>
                <td width="76%" class="new">'.$CommDate_blog.'</td>
              </tr>
		  <tr>
                <td width="76%" class="new"> </td>
              </tr>
                    <tr>
                      <td>'.$Description_blog.'</td>
                    </tr>
				<tr>
                      <td style="border-bottom:1px solid #ffa2b5;"> </td>
                    </tr>';
				 	} 
$BlogCommentsdis.='<tr>
                      <td><table width="65%"  border="0" align="center" cellpadding="3" cellspacing="3">
  <tr>
    <td width="97%" align="right">';
	if($limit < $total)
	{
			if ($page == 1)
			{
				echo ""; 
			}
			else 
			{       
				$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=" . ($page - 1) . "\" class='linksnew'>Prev</a>"; 
			}
			for ($i = 1; $i <= $pager->numPages; $i++) 
			{ 
				$BlogCommentsdis.=" | "; 
				if ($i == $pager->page)
				{ 
					$BlogCommentsdis.="<span class='Hint1'>"."$i"."</span>"; 
				}
				else
				{	 
					$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=$i\" class='linksnew'> $i</a>"."</font>"; 
				}
			} 

			if ($i > 1)
			{
			 $BlogCommentsdis.=" | "; 
			}
	  
			if ($page == $pager->numPages) 
			{
			$BlogCommentsdis.="";
			} 
			else   
			{     
				$BlogCommentsdis.="<a href=\"".$_SERVER['PHP_SELF']."?task=MTQ=view&sortby=".$SortList."&page=" . ($page + 1) . "\" class='linksnew'>Next</a>";
			}
	}	


$BlogCommentsdis.='</td>
    <td width="3%" align="right"> </td>
  </tr>
</table></td>
                    </tr>';
				}
$BlogCommentsdis.='</table>   </td>  </tr>  <tr>
    <td> </td>
  </tr>';

$BlogCommentsdis.='</table>';

?>

 

Any help is appreciated.

 

Thanks again.

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.