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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:15:24+00:00 2026-06-03T20:15:24+00:00

just created a form that saves the filename into an SQL database. The thing

  • 0

just created a form that saves the filename into an SQL database.

The thing is that when I ad the ID column(Auto increment) into the SQLDatabase the form stops to save my filename, but as soon I delete the ID row, it begins to save.

Dont know whats the problem.

this is some of my code

 <?php  



     if(isset($_FILES['file_name'])) {
     $file_name = mysql_real_escape_string($_FILES['file_name']['name']); 
      //Writes the information to the database 

     mysql_query("INSERT INTO `files` VALUES ('$file_name')") ; 
      }

     //Retrieves data from MySQL 
     $data = mysql_query("SELECT * FROM files") or die(mysql_error()); 
     //Puts it into an array 

     ?> 

And my database has two columns file_id and file_name
but as I just wrote, the file_id wont work =/

Any ideas ?

  • 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-03T20:15:26+00:00Added an answer on June 3, 2026 at 8:15 pm

    I think you need to change your SQL query to this:

    mysql_query("INSERT INTO `files` (`file_name`) VALUES ('$file_name')") ; 
    

    With more than one column, you need to name which column you want the $file_name string to be saved in if you’re not going to enumerate every column in the table. Then your auto-increment should work fine.

    In fact, the problem isn’t with auto-increment, it’s with your SQL syntax. You should check your queries for errors by saving the return value from mysql_query and checking if it returned false. If it did, call mysql_error to determine the error message.

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

Sidebar

Related Questions

I just created a PHP page that spits outs some data from my database
I have created application where i just need to access data form assets folder.
I have a form that has all the fields pulled dynamic from a database
I have a form that is dynamically created. It is a winForms application. This
Using CakePHP 1.3 , I have a (working) form that has dynamically created form
Just like in topic I try to create a form when the elements create
I'm trying to create a Windows Form application in C#, mostly just to practice
Just created a WSS site with a some custom web-parts. But I get an
Just created an acc on SO to ask this :) Assuming this simplified example:
I just created a ASP.NET MVC project and was able to build and browse

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.