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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:59:12+00:00 2026-06-02T08:59:12+00:00

So I am trying to make this website that takes in the values that

  • 0

So I am trying to make this website that takes in the values that are given to it by a text document and pout them into a mySQL database. The code I am running in my php doesn’t give me any syntax errors, but the values aren’t added to the database tables.

 $upload = new mysqli('localhost', 'uMoviesRoot', $_POST['password1']);

if (mysqli_connect_errno()) {
 echo "There as an error.";
 }

 else {
 mysql_select_db("localhost");
 $file= fopen($_FILES['Upload']['tmp_name'], 'r');

 while(! feof($file)){


$line = fgetcsv($file, 999);
if ($line[0] == "movie") {
    mysql_query("INSERT INTO movies (movie, year) VALUES ($line[1], $line[2])");    
    $movieCount++;
    $lastMovie = $line[1];

}

Just some background, I have created the tables in mySQL (using MySQL workbench) and made a schema named movies. There are tables named actors(2 columns), directed_by (2 columns), directors(1 column), movies(2 columns), and performed_in (3 columns). I only put one of these additions in the code just to make it shorter (since all of the ifs do the same thing).

Is this a problem with my PHP code?

  • 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-02T08:59:20+00:00Added an answer on June 2, 2026 at 8:59 am

    You should mysql_select_db("movies");, localhost is your server address and not the database name.

    UPDATE (not testet but this should work):

    $upload = new mysqli('localhost', 'uMoviesRoot', $_POST['password1']);
    
    if (mysqli_connect_errno()) {
      echo "There as an error.";
    } else {
      mysql_select_db("movies");
      $file= fopen($_FILES['Upload']['tmp_name'], 'r');
    
      while(! feof($file)){
        $line = fgetcsv($file, 999);
        if ($line[0] == "movie") {
          mysql_query("INSERT INTO movies (movie, year) VALUES ('$line[1]', '$line[2]')");    
          $movieCount++;
          $lastMovie = $line[1];
        }
      }
    }
    

    You could also output mysql_error to see the errors.

    If you have values from user input, you should have a look at Prepared Statements to avoid SQL injection, etc.

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

Sidebar

Related Questions

I have been trying to make this to be a little jQuery plugin that
Okay, so I'm trying to make this bigger: Post: <input id=postbox type=text rows=6 cols=40
So I have this select statement that I am trying to make more responsive.
I have been trying to make my website performs well. One way that may
I'm trying to make this website: http://501commons.org render the same on iPhone as on
I'm trying to make a website that allows you to A) Edit FLA files
so I've been trying to make this bot in python that uses sockets to
I'm trying to make a nice-looking CSS menu, for this website . (The domain
I am trying to make this landscape only iphone app. I only use this
I'm trying to make this fragment work: Version History --------------- These are the versions

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.