Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:06:44+00:00 2026-06-17T16:06:44+00:00

i am uploading some data to the db that contain title, news date and

  • 0

i am uploading some data to the db that contain title, news date and image, but when i want to update it i am facing problems.what i want to do basically if i update all the row except image then updation do not take place. what i want basically when i have to update lets suppose title only then it should update it but all other data should remain same but problem is that i have to select image again from my pc in updation. my scenario is that i just save the name in db not the whole path and hard code the path where ever i need to display the image

here is html

 <div class="row">
                            <label>Image upload</label>
                            <div class="right"><input type="file" name="file" value="<?php echo $row['images'];?>" /></div>
                        </div>

here is php

   if(($_GET['mod']=='edit') && (isset($_POST['hidden'])))
{




    echo $_FILES["file"]["name"];
        $allowedExts = array("jpg", "jpeg", "gif", "png");
        $extension = end(explode(".", $images));
        if ((($_FILES["file"]["type"] == "image/gif")
        || ($_FILES["file"]["type"]   == "image/jpeg")
        || ($_FILES["file"]["type"]   == "image/png")
        || ($_FILES["file"]["type"]   == "image/pjpeg"))

        && in_array($extension, $allowedExts))
          {
           if ($_FILES["file"]["error"] > 0)
            {

            echo $_FILES["file"]["error"] . "<br>";
            }
          else
            {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload-images/" . $images);
            $update="UPDATE headline SET 
                                                headline_title  = '$title',   
                                                headline_des    = '$description',   
                                                month           = '$month_name', 
                                                day             = '$day_name', 
                                                year            = '$year_name', 
                                                featured        = '$featured',
                                                headline        = '$headline',
                                                images          = '$images' 
                                                where id        = ".$_GET['id']."";
             $result = mysql_query($update);    

              }
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:06:45+00:00Added an answer on June 17, 2026 at 4:06 pm

    Submitting the form again will cause the new value of the file input which will be empty
    so you have to check if it’s empty or not and act according to the status

    For example

    if($_FILES['file']['name'] != "")
    {
          //upload the image with what ever you want 
          //move_uploaded_file($_FILES['file']['tmp_name'],$target.$image );
          //the SQL query should contain the updating the image column 
             if(($_GET['mod']=='edit') && (isset($_POST['hidden'])))
             {
    
    
    
    
    echo $_FILES["file"]["name"];
        $allowedExts = array("jpg", "jpeg", "gif", "png");
        $extension = end(explode(".", $images));
        if ((($_FILES["file"]["type"] == "image/gif")
        || ($_FILES["file"]["type"]   == "image/jpeg")
        || ($_FILES["file"]["type"]   == "image/png")
        || ($_FILES["file"]["type"]   == "image/pjpeg"))
    
        && in_array($extension, $allowedExts))
          {
           if ($_FILES["file"]["error"] > 0)
            {
    
            echo $_FILES["file"]["error"] . "<br>";
            }
          else
            {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload-images/" . $images);
            $update="UPDATE headline SET 
                                                headline_title  = '$title',   
                                                headline_des    = '$description',   
                                                month           = '$month_name', 
                                                day             = '$day_name', 
                                                year            = '$year_name', 
                                                featured        = '$featured',
                                                headline        = '$headline',
                                                images          = '$images' 
                                                where id        = ".$_GET['id']."";
             $result = mysql_query($update);    
    
              }
            }
    }
    else
    {
          //SQL update without image 
            $update="UPDATE headline SET 
                                                headline_title  = '$title',   
                                                headline_des    = '$description',   
                                                month           = '$month_name', 
                                                day             = '$day_name', 
                                                year            = '$year_name', 
                                                featured        = '$featured',
                                                headline        = '$headline'
                                                WHERE id        = ".$_GET['id']."";
             $result = mysql_query($update);    
    
    }
    

    if you don’t want the image to be edited simply you can remove it from the update and the form used for that or but it’s path in hidden input

    Hope this will help

    According to your comment the query should look something like this

            $update="UPDATE headline SET 
                                                headline_title  = '$title',   
                                                headline_des    = '$description',   
                                                month           = '$month_name', 
                                                day             = '$day_name', 
                                                year            = '$year_name', 
                                                featured        = '$featured',
                                                headline        = '$headline'
                                                WHERE id        = ".$_GET['id']."";
             $result = mysql_query($update);    
    

    I think you need to use good intending to make your code more readable and maintainable in the future 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am uploading/downloading some data in my application using AsyncTask. What I want is
Can anyone give me some idea about uploading data from excel to access database
I’ve been trying to follow some examples for uploading data to a website. I
I'm working on a project that involves uploading an image to tumblr from Python.
I have read that some graphics cards benefit if you align your vertex data
I am developing an iOS application that has the capability of uploading data to
I have a REST interface for uploading some data stored on my local Android
I am using FileUpload control of asp.net and uploading the excel with some data.
I'm developing a content uploading tool that is currently GETing the html data in
I'm having some difficulties with uploading an image from an html form. The form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.