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?