Reteriving names based on id not working

hi folks i m working on a query and its giving me error saying
mysql_fetch_array(): supplied argument is not a valid
I don’t know where i m going wrong i been over it again n again
here is my code


<?php require("includes/functions.php"); ?>
<?php
if(isset($_GET['page'])){
    $sub = $_GET['page'];
    $sub_sel =  get_heading($sub);
    
}else{
    $sub = "";
}
?>
<body>

<div class="container">
  <div class="sidebar1">
  <?php 
  $con = mysql_connect("localhost","root","");
  confirm($con);
  $seldb = mysql_select_db("widget_corp");
 confirm($seldb);
 //$query = "select * from subjects";
//$subject_set = mysql_query($query);
 $parent = get_subjects($subject);
?>
<ul>
    
<?php 
 while($subjects=mysql_fetch_array($parent))
 {
         echo "<a href=\\"\\"><li>{$subjects["menu_name"]}</a></li>";
            
            $pageResult = get_pages($subjects["id"]);
            echo "<ul class=\\"nested\\">";
            while($row = mysql_fetch_array($pageResult)){
                echo "<a href=\\"content.php?page=" . urlencode($row["id"]). "\\"><li>{$row["menu_name"]}</a></li>";
            }
            echo "</ul>";
 }
  ?>
</ul>  
    </div>
  <div class="content">
  
  <h1><?php $sub_sel["menu_name"] ?></h1>
    <?php
        echo ($sub);
        ?>
    <!-- end .content --></div>
  <!-- end .container --></div>

and here is that function


function get_heading($subject_id){
    $query ="SELECT * FROM"; 
    $query .= "subjects "; 
    $query .= "where id = {$subject_id}";
    $query .= "limit by 1";
    $result_set = mysql_query($query);
    if($subject = mysql_fetch_array($result_set)){
        return $subject;
    }else{
        return null;
    }
}

what am i doing wrong

Limit 1

Yea, ‘limit 1’ not ‘limit by 1’.

Also, your code is dangerous security wise - please read up on Sql Injection and mysql_real_escape_string

http://php.net/manual/en/function.mysql-real-escape-string.php