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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:15:40+00:00 2026-06-04T04:15:40+00:00

I have a CSV file uploaded to the same directory as the file containing

  • 0

I have a CSV file uploaded to the same directory as the file containing the email addresses of people I want to delete from a table (all at once) in my database. The code I’m using echoes correctly but doesn’t delete anything from the table. The CSV file is uploaded to the same directory as the file containing the code below.

<?php
    // Make a MySQL Connection
    mysql_connect("x", "x", "x") or die(mysql_error());
    mysql_select_db("volunteers2012") or die(mysql_error());
    mysql_query($sql);
    /********************************/

    $addresses = file('deleteEmails.csv');
    foreach($addresses as $address) {
        $safe_address = mysql_real_escape_string($address);
        $sql = "DELETE FROM vols2012 WHERE `email` = '$safe_address'";
        $result = mysql_query($sql) or die(mysql_error());
    }
    echo "DELETION A GREAT SUCCESS!";
    ?>

Round 2- Trying with a .txt file

<?php
    // Make a MySQL Connection
    mysql_connect("x", "x", "x") or die(mysql_error());
    mysql_select_db("volunteers2012") or die(mysql_error());
    mysql_query($sql);
    /********************************/

    $addresses = "LOAD DATA LOCAL INFILE ('deleteEmails.txt')";
foreach($addresses as $address) {
$safe_address = mysql_real_escape_string($address);
$sql = "DELETE FROM vols2012 WHERE (email = '$safe_address')";
$result = mysql_query($sql) or die(mysql_error());
   }
    echo "DELETION A GREAT SUCCESS!";
    ?>

I’m still getting the success echo, but with the error- Invalid argument supplied for foreach().

  • 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-04T04:15:41+00:00Added an answer on June 4, 2026 at 4:15 am

    I wound up not using the upload to delete method and instead created an html page w/ checkboxes to delete by hand. In the end this was the best method as I needed to leave some of the records in one table but not the other.

              <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <?php
    
    
           // Delete the customer rows (only if the form has been submitted)
    
             if(isset($_POST['submit']))
          {
          foreach($_POST['todelete'] as $delete_id) {
    
                 $query="DELETE FROM volConfirm WHERE email='$delete_id'";
    
    
                    mysql_query($query) or die ('Error in query: ' .mysql_errno() . mysql_error());
                }
    
    
            }
    
    
            // Display the customer rows with checkboxes for deleting
            $query="SELECT * FROM volConfirm";
    
            $result = mysql_query($query);
            while ($row = mysql_fetch_array($result)){
            echo '<input type="checkbox" value="' . $row['email'] .'"name="todelete[]" />';
            echo $row['agreeName'];
            echo ' '.$row['position'];
            echo ' '.$row['shift_times'];
            echo ' '.$row['email'];
            echo ' '.$row['confirmed'];
            echo '<br />';
            echo '<br />';
           }
         ?>
    
            <input type="submit" name="submit" value="Remove" />
          </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have CSV file and Macro in VBA. I want to open CSV file
i have csv files, java app and database, i read csv file from my
I have a csv file : 1|1.25 2|23.56 3|58.99 I want to put this
I have a csv file from which I have to populate different tables in
I uploaded a csv file to MySQL DB but for some reason data from
I have a csv file uploaded and data read into an array .The valid
I have a process where a CSV file can be downloaded, edited then uploaded
My problem is, i have the site in which .CSV file is uploaded and
I have a requirement to export some data from a table (not all fields
I have csv file with 14 columns and I want to sort it in

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.