Support » Fixing WordPress » Droping Database Tables.

  • I have recently upgraded to wp 2.0 from wp 1.5 and I would like to delete ALL the info in my SQL tables and start over again. Since I do not have acess to PhpMyAdmin or similar programs I have decided to write a php script that would deleate all the info in my tables. So far I have:

    // Connect to database
    $connect = mysql_connect('localhost', 'USERNAME', 'PASSWORD')
    or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    // Select Database
    mysql_select_db('DATABASE') or die('Could not select database')

    // Deleating
    $delete = 'WTF GOES HERE?';
    $result = mysql_query($delete) or die('Failed to delete: ' . mysql_error());

    // Close Connection

    my question is what should go in the $delete place to acomplish this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Depending on how familiar you are with the mysql functions in PHP, you have two options:

    1. Get the list of all the tables that you have in the database manually, and then run the following as your $delete:

    $delete = "DROP TABLE TABLENAME";

    2. Take a look here:

    And then write out a loop to run through all the tables found in your database, and run a similar $delete command for each table.

    Hope this helps. Be CAREFUL and BACKUP your database before you do this, since it cannot be reversed, and if something goes wrong you should still have your data.

    Ok, sounds good, now to see if it works as sugested. I will post my results here.

    Thanks for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Droping Database Tables.’ is closed to new replies.