Hi,

I have this script

<?php require_once("includes/connection.php")?>
<?php require_once("includes/functions.php")?>
<?php 
   if (intval($_GET['subj']) == 0){
       redirect_to("content.php");
       } 
       
    $submit = $_POST['submit'];  
   if (isset($submit)){
         //for validation

        $errors = array(); 
        $required_fields = array('menu_name', 'position', 'visible');
        foreach($required_fields as $fieldname){
            if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && !is_numeric($_POST[$fieldname]))){
            $errors[] = $fieldname;
                }
        }
            $fields_with_lengths = array('menu_name' => 30);
            foreach($fields_with_lengths as $fieldname => $maxlength){
                if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength){
                    $errors[] = $fieldname; }
                }     
       
if (empty($errors)){
    //perform update
$id = mysql_prep($_GET['subj']);       
$menu_name = mysql_prep($_POST['menu_name']);
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);

$query = "UPDATE subject SET
              menu_name = '{$menu_name}',
              position = {$position}, 
              visible =  {$visible}
         WHERE id =    {$id}";
$result = mysql_query($query, $connection);
if (mysql_affected_rows() == 1){
    //seccess
    }else {
        //failed
        }           
}else {
    //Errors occured
    }


        } //end    if (isset($_POST['submit'])){
?>
<?php find_selected_page();    ?> 
<?php include("includes/header.php")?>
<table id="structure">
    <tr>
        <td id="navigation">
        <?php
        echo naviation($sel_subject, $sel_page) ;     
        ?>      
        </td>
        <td id="page">
           <h2>Edit Subject: <?php echo $sel_subject['menu_name']?></h2>
           <form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']);?>" method="post">
           <p>Subject name:
           <input  type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>" id="menu_name"/></p>
           <p>Position:
           <select name="position">
           <?php $subject_set = get_all_subjects();
                 $subject_count = mysql_num_rows($subject_set);
                 for ($count=1; $count<= $subject_count + 1; $count++){
                     // $subject_**** + 1 becouse we are adding a subject
                     echo "<option value=\"{$count}\"";
                     if ($sel_subject['position'] == $count){
                         echo " selected=\"selected\"";
                         }
                     echo ">{$count}</option>";
                     }
           ?>
           </select></p>
           <p>Visible:
           <input name="visible" type="radio" value="0" <?php if ($sel_subject['visible'] == 0){echo " checked"; }?> /> No
           <input name="visible" type="radio" value="1" <?php if ($sel_subject['visible'] == 1){echo " checked"; }?> /> Yes</p>
           <input type="submit" name="submit" value="Edit Subject" />
           
           </form>
           <br />
           <a href="content.php">Cancel</a>
        </td>
    </tr>
</table>
<?php require("includes/footer.php"); ?>

When I run this script id don't show any errors but it don't edit data... I have checked everything and don't find any thing wrong.

can somebody help me please

Try and echo messages on your file to track the flow of your code.
debuging is very important.

You have 2 includes so no one can know what the 2 includes contains.

Try echo bug checks ok??

very handy php error check

Explore :)