Retrieving data in php
<p>I've created a page where I've place for updating the attachment. While doing so, if a file with same name, size, extension is attached, the attachment table need not be updated. This is the scenario. This is how I tried to do:</p>

<pre><code>  else if($mode == "attachment_update") {
            $id = intval(mysqli_real_escape_string($mysqli, $_REQUEST["_id"]));
            $upload_directory = "upload/attachment/";
            $result = file_upload("attachment", "../".$upload_directory);

            $file_name = '".addslashes($result[file_name])."';
write_log($file_name);
            $file_extension = '".$result[file_extension]."';
write_log($file_extension);
            $file_size = '".$result[file_size]."';
write_log($file_size);
            $uploaded_file_name = '".$result[uploaded_file_name]."';
write_log($uploaded_file_name);
            $uploaded_file_path = '".$upload_directory.$result[uploaded_file_name]."';
write_log($uploaded_file_path);

            $query_select = "SELECT
                              file_name,
                              file_extension,
                              file_size,
                              uploaded_file_name,
                              uploaded_file_path
                            FROM
                              attachments
                            WHERE
                              id = 'id';";
            $result1 = mysqli_query($mysqli, $query_select) or throwexception(mysqli_error($mysqli));                 
            $row = mysqli_fetch_row($result1);

            write_log($row[0]);
            write_log($row[1]);
            write_log($row[2]);
            write_log($row[3]);
            write_log($row[4]);


            if($row[0] == $file_name &amp;&amp; 
               $row[1] == $file_extension &amp;&amp; 
               $row[2] == $file_size &amp;&amp; 
               $row[3] == $uploaded_file_name &amp;&amp; 
               $row[4] == $uploaded_file_path) 
            { 
                write_log("inside if"); 
            } else {
                if($result[status] == true) {
                        $query = "UPDATE
                                  attachments
                                SET
                                  file_name = '".addslashes($result[file_name])."',
                                  file_extension = '".$result[file_extension]."',
                                  file_size = '".$result[file_size]."',
                                  uploaded_file_name = '".$result[uploaded_file_name]."',
                                  uploaded_file_path = '".$upload_directory.$result[uploaded_file_name]."',
                                  recorded_by = '$recorded_by',
                                  recorded_datetime = '$recorded_datetime'
                                WHERE
                                  id = 'id';";
                        mysqli_query($mysqli, $query) or throwexception(mysqli_error($mysqli));
                    }
            }


            echo json_encode(array("message" =&gt; "Updated successfully"));
            exit;
        }
</code></pre>

<p>The if condition does the thing. If all are true, the table will not be updated. If even any one fails, the table will be updated. </p>

<p>Here the problem is $file_name, $file_extension, $file_size, $uploaded_file_name are going null. I don't know how to retrieve it. Can someone tell how to retrieve those data, so that if can check it with the if condition?</p>