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 9034673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:32:55+00:00 2026-06-16T08:32:55+00:00

Here is the issue: The file name is not being saved into the database.

  • 0

Here is the issue: The file name is not being saved into the database. Files are being uploaded to the server just fine, yet the file name will not save at all. I can echo the file name once the file is uploaded successfully but it does want to save the filename to the database for whatever reason. I’m sure this is an easy fix and I’m just missing something (I hope).

Thanks in advance.

(p.s. yes, I know I should be using mysqli)

HTML:

<form action="" name="loa" method="post" enctype="multipart/form-data">
    <input type="hidden" name="size" value="350000">
    <input type="file" name="loa"> 
    <input type="submit" name="loasub" value="Upload Letter of     Authorization">
</form>

PHP:

<?php
    if (!empty($_POST['loasub'])) {
        $target = "loa/";
        $target = $target . basename( $_FILES['loa']['name']);
        $theloa = ($_FILES['loa']['name']);
        mysql_connect("localhost", "user", "pass") or die(mysql_error()) ;
        mysql_select_db("mydb") or die(mysql_error()) ;

        //Writes the information to the database
        mysql_query("UPDATE customers SET loa='$theloa' WHERE id='30'") ;
        if(move_uploaded_file($_FILES['loa']['tmp_name'], $target))
        {
            echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
            echo $theloa;
        }
        else {
            echo "Sorry, there was a problem uploading your file.";
        }
    }
?>
  • 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-16T08:32:56+00:00Added an answer on June 16, 2026 at 8:32 am

    A couple of things to consider:

    1. mysql_* functions are deprecated. Use mysqli or PDO instead.
    2. Your query can break if the variable $theloa has a single quote in it. Use prepared statements to prevent such errors and prevent (siren sounds and red lights flashing) SQL injection.

    Consider doing a var_dump($_FILES['loa']['name']) and pasting it in with your question for more clarity.

    Try using the following modified mysqli version of your file (you need to have the mysqli extension enabled in your PHP installation). It should (ideally) work.

    <?php
        if (!empty($_POST['loasub'])) {
    
            $theloa = ($_FILES['loa']['name']);
            $target = "loa/";
            $target = $target . basename($theloa);
    
            $mysqli = new mysqli("localhost", "user", "password", "mydb");
            if (mysqli_connect_errno()) {
                die(mysqli_connect_error());
            }
    
    
            //Writes the information to the database
            if ($preparedStatement = $mysqli->prepare("UPDATE customers SET loa=? WHERE id=30")) {
                $preparedStatement->bind_param("s", $theloa);
                $executionResult = $preparedStatement->execute();
                if (!$executionResult) {
                    die("Query execution failed!");
                }
                //$preparedStatement->bind_result($sqlOutput); // bind mysql output to an output variable
                //$preparedStatement->fetch(); // fetch mysql output
                //var_dump($sqlOutput); // dump the sql output
    
                $preparedStatement->close();
            }
            $mysqli->close();
    
            if(move_uploaded_file($_FILES['loa']['tmp_name'], $target))
            {
                echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
                echo $theloa;
            }
            else {
                echo "Sorry, there was a problem uploading your file.";
            }
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really weird issue here. I'm using my local development server right
Im having a weird issue here. Its probably just something stupid but I dont
I'm having a bit of an issue uploading files to a database. The table
I have a strange issue where my virtual hosts are not being restricted when
I have run into an issue in which IE does not open up the
I am facing some issues in loading a CSV file through SQL Loader. Here
My issue here is quite simple : i'm trying to use the jQuery validate
Having an issue here that I have tried everything I can think of but
I am facing a issue here in reading the values set by a stored
I'm having a small issue here: <div id=navbar> <ul id=navtabs class=floatcontainer> <li <?php if

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.