supplied argument is not a valid MySQL result

Posted by jasmine on Stack Overflow See other posts from Stack Overflow or by jasmine
Published on 2010-04-21T16:28:53Z Indexed on 2010/04/21 16:33 UTC
Read the original article Hit count: 170

Filed under:

I have written a function:

function selectWithPaging($where){

 $pg = (int) (!isset($_GET["pg"]) ? 1 : $_GET["pg"]);
 $pg = ($pg == 0 ? 1 : $pg);
 $perpage = 10;//limit in each page
 $startpoint = ($pg * $perpage) - $perpage;
 $result = mysql_query("SELECT * FROM $where ORDER BY id ASC LIMIT $startpoint,$perpage");
 return $result;
               }

but when inserting in this function :

function categories() { 

 selectWithPaging('category') 
 $text .='<h2 class="mainH">Categories</h2>';
 $text .= '<table><tr class="cn"><td>ID</td><td class="name">Category</td>  <td>Durum</td>'; 
 while ($row = mysql_fetch_array($result)) {
 $home    = $row['home']; 
 $publish = $row['published'];
 $ID = $row['id'];
 $src = '<img src="'.ADMIN_IMG.'homec.png">';
                      -------------
          }

there is this error: supplied argument is not a valid MySQL result

What is wrong in my first function? Thanks in advance

© Stack Overflow or respective owner

Related posts about php