FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


how to solve that error .. mysql_num_rows() ....





HTET-HTET
Hi ...
I have some confusing error logs like:


PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/g9kstl6o/public_html/MYANMARTRAVELOPERATOR.COM/index.php on line 245


please solve for me ...

Thanks & Regards
Htet Htet Win
Peterssidan
It sounds like the arguments you pass to mysql_num_rows is not valid. The argument should be the result from calling mysql_query.
HTET-HTET
Thanks Peterssidan ...
may i show you my some of code ... that is already ok on my local (only pc). but when i upload that code to our hosting .. above that error happening . no one can't select any data .. please check for me .. Thanks again ...

// That is index.php
Code:
<?
   include "config.php";
   $sqlcon=new db_sql();
   $sqlcon-> connect();
   
   
?>
   <ul id="countrytabs" class="shadetabs"  style=" padding-left:10px; padding-top:2px;" >

<li><a href="#" rel="country1" class="selected" style="line-height:17px;background-color:#e1ebf7;">A-F</a></li>
<li><a href="#" rel="country2" style="line-height:17px;background-color:#e1ebf7;">G-L</a></li>
<li><a href="#" rel="country3" style="line-height:17px;background-color:#e1ebf7;">M-R</a></li>
<li><a href="#" rel="country4" style="line-height:17px;background-color:#e1ebf7;">S-X</a></li>
<li><a href="#" rel="country5" style="line-height:17px;background-color:#e1ebf7;">Y-Z</a></li>


</ul>

<div style=" width:300px; margin-bottom: 1em; padding: 10px;" >

<div id="country1" class="tabcontent">
 <?        $sql2="SELECT * FROM nation WHERE nation REGEXP '^a' or  nation REGEXP '^b' or  nation REGEXP '^c' or  nation REGEXP '^d'  or  nation REGEXP '^e' or  nation REGEXP '^f'";               
            $result2 = mysql_query($sql2);               
             $row = mysql_num_rows($result2);
         
              for($i=1;$i<=$row;$i++)
             {
                   $rec = mysql_fetch_array($result2);
                  $nation = $rec["nation"];
   //echo ' <input type="hidden" name="mystate" value="submit" id="mystate">'; onclick=mystate.value=\''.$nation.'\';topform.target=";topform.submit();"
                  if(isset($_REQUEST["id2"]) && $_REQUEST["id2"]!="")
                  {
                   echo '<div style="width: 25%; float: left; padding-left:5px; padding-bottom:5px;  padding-right:5px; "><a href="?id='.$nation.'&id2='.$_REQUEST["id2"].'&type='.$_REQUEST["type"].'" onclick="javascript:submit1();" class="subtext">'.$nation.'</a>                  
                  </div>';
                  }
                  else
                  {
                     echo '<div style="width: 25%; float: left; padding-left:5px; padding-bottom:5px;  padding-right:5px; "><a href="?id='.$nation.'&type='.$_REQUEST["type"].'" onclick="javascript:submit1();" class="subtext">'.$nation.'</a>                  
                  </div>';
                  }
               
             } ?>

</div>


That is config.php
Code:
 <?
 class db_sql
 {
 function connect()
    {
      $mysql=mysql_connect("localhost","REMOVED","REMOVED");
      if(!$mysql)
      {
         echo "Cannot Connect Server". mysql_error();
      }
      else
      {
         $db=mysql_select_db("cs");
         if($db) return true;
         else return false;
      }
   }
 }
?>


MOD Edit wrote:
mathiaus: Removed MySQL username & Password
kacsababa
You know you just provided the mysql username and password Question Exclamation

Regard the problem most likely your $result2 is a false boolean, because there is an error durring the query, you should put a condition in, for example terminate it on error:
Code:
$result2 = mysql_query($sql2) or die(mysql_error());
mathiaus
Please be careful when posting code containing configuration settings.
HTET-HTET
mathiaus wrote:
Please be careful when posting code containing configuration settings.



Thanks of your advice ...
HTET-HTET
Thanks for all of help..
i have new one error message again ..

[<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied


please how to fix it ... help me ...




Regards...
HTET HTET WIN
Fire Boar
Your username and password are wrong. Check that the username/password combo exists and has the appropriate permissions on the database.

Also, your query is a bit unnecessarily long. If you're going to use REGEXP you might as well take advantage of regular expressions:

Code:
SELECT * FROM nation WHERE nation REGEXP '^[a-f]'
HTET-HTET
Fire Boar wrote:
Your username and password are wrong. Check that the username/password combo exists and has the appropriate permissions on the database.

Also, your query is a bit unnecessarily long. If you're going to use REGEXP you might as well take advantage of regular expressions:

Code:
SELECT * FROM nation WHERE nation REGEXP '^[a-f]'


Thanks of your explain and pointing .... Thanks you so much ... now .. all error are fix ...

Regards
Htet Htet Win
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.