Retrieving data in php -


i've created page i've place updating attachment. while doing so, if file same name, size, extension attached, attachment table need not updated. scenario. how tried do:

  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                                                           attachments                                                           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 &&                 $row[1] == $file_extension &&                 $row[2] == $file_size &&                 $row[3] == $uploaded_file_name &&                 $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'                                                                   id = 'id';";                         mysqli_query($mysqli, $query) or throwexception(mysqli_error($mysqli));                     }             }               echo json_encode(array("message" => "updated successfully"));             exit;         } 

the if condition thing. if true, table not updated. if 1 fails, table updated.

here problem $file_name, $file_extension, $file_size, $uploaded_file_name going null. don't know how retrieve it. can tell how retrieve data, if can check if condition?

in case, not need fire select query. add and condition in update query.

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 = "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'                                                   id = 'id'                           , 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] . "', ;";     mysqli_query($mysqli, $query) or throwexception(mysqli_error($mysqli));      echo json_encode(array("message" => "updated successfully"));     exit; } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -