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

  • Home
  • SEARCH
  • 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 6627401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:00:34+00:00 2026-05-25T22:00:34+00:00

I am really struggling trying to get something very simple achieved. Essentially, I have

  • 0

I am really struggling trying to get something very simple achieved.

Essentially, I have an images table called galleryimages and a location on the server where images are stored. What I am trying to do is overwrite the source field for a given category in the table while the upload is going through.

My code will add the new image to the server, but not update the MySQL table for some reason (I can however add new lines to it although I want to keep the existing data in the table and simply change the “photo” field which locates the image).

My PHP is:

<?php include 'dbc.php'; page_protect();

    if(!checkAdmin()) {header("Location: login.php");
    exit();
    }

    $host  = $_SERVER['HTTP_HOST'];
    $host_upper = strtoupper($host);
    $login_path = @ereg_replace('admin','',dirname($_SERVER['PHP_SELF']));
    $path   = rtrim($login_path, '/\\');

    foreach($_GET as $key => $value) {
        $get[$key] = filter($value);
    }

    foreach($_POST as $key => $value) {
        $post[$key] = filter($value);
    }   
?>


<?php 
    if($_FILES['photo']) 
    {
        $target = "galleries/test/"; 
        $target = $target . basename( $_FILES['photo']['name']); 

       $title = mysql_real_escape_string($_POST['title']); 
        $pic = "galleries/test/" .(mysql_real_escape_string($_FILES['photo']['name']));
    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
    {
        mysql_query("update `galleryimages` set (`title`, `photo`) VALUES ('$title', '$pic')") ;     

        echo "Success"; 
    } 
    else 
    { 
        echo "Failure"; 

    }
    } 
?> 

And the HTML is:

```html
  </head>
  <body>

        <form enctype="multipart/form-data" action="addgallery1.php" method="POST">
          <table width="100%" border="2" cellpadding="5"class="myaccount">
             <tr>
               <td>Category: </td>
               <td><select name="title" id="select8">
                  <option value="Landscape Pots">Landscape Pots</option>

                      </select></td>
            </tr>
           <tr>
               <td>Image: </td>
               <td><input type="file" name="photo" /></td>
            </tr>
             <tr>
               <td colspan="2"><input type="submit" class="CMSbutton" value="Add" /></td>
             </tr>
          </table>
        </form>

        </body>
        </html>

Now I am fairly sure the problem exists in the line:

    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
    {
        mysql_query("update `galleryimages` set (`title`, `photo`) VALUES ('$title', '$pic')") ;     
        echo "Success"; 
    } 

but need some help to determine if this is indeed the case – and if so how I can get it to update the MySQL table – at the moment the PHP echoes Success but does not make any update to the “photo” column in MySQL.

Hope this makes sense and one of you coding geniuses can help me resolve this – its taken me hours of trial and error but still cant get it working!!!

thanks in advance to any and all help

JD

  • 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-05-25T22:00:35+00:00Added an answer on May 25, 2026 at 10:00 pm

    some thing wrong here

     mysql_query("update `galleryimages` set (`title`, `photo`) VALUES ('$title', '$pic')") ;
    

    it should be like

    mysql_query("update `galleryimages` set `title`='$title', `photo`= '$pic'") ;
    

    more info here: http://dev.mysql.com/doc/refman/5.0/en/update.html

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

Sidebar

Related Questions

I am trying to get a date picker working and I am really struggling
I have been struggling with a problem trying to get PLJava to work on
I'm trying to get to learn som javascript/jQuery stuff, and I'm really struggling with
Really struggling to figure this out. Just trying to take in data from php
I am trying to read the following xml stream but am really struggling. <channelSnapshot
Hey, I'm really struggling with this one. I'am trying to port a small piece
I'm really struggling to wrap my head around this: I have a UserModel and
I'm sure this is a piece of cake but I'm really struggling with something
I am trying to learn Spring and Hibernate and i am really struggling to
I'm really struggling trying to use the jQuery UI autocomplete plugin. I've had a

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.