FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP - Droping & Emtpying unknown tables





deathseaker
Ok on my site for some reason if i dont emtpy a database then when i drop it and recreate it, it will have all the entrys still in it. So i was wondering if somone could help me determine some kind of script that will figure out how many tables there are, then emtpy them, after that drop the tables or is this impossible? Sad

- deathseaker

Thanx in advance!
pollux1er
Just take the habit to unload a table before drop it.
deathseaker
lol nooo i know that i am asking for a script that will search for ALL tables and emtpy them it will be an unknown amount so i cant jsut do it by table names =/ or is it not possible
deathseaker
well here is the verzion i came up with...

Code:

<?php
$result = mysql_list_tables($db_database);

if (!$result)
{
    print "DB Error, could not list tables\n";
    print 'MySQL Error: ' . mysql_error();
    exit;
}


while ($row = mysql_fetch_row($result))
{
    $table = row[0];
    $query = "TRUNCATE TABLE '$table'";
    processQuery($query);
    $query = "DROP TABLE '$table'";
    processQuery($query);
       
}
?>


processQuery connects to the database and does all that stuff for me..
Related topics
PHP: Feedback form issues.. help =P
types of cell phones?
Lists of Modding site..
PHP function(); &file=""?
Your favourite book (official)
Need script
XP Recovery - My Documents inaccessible
What games you play online??
I need help installing php-nuke
"DESIGNER" Barra de loading no FLASH
PLEASE, PLEASE HELP
Jaarlijkse HCC beurs Utrecht
Please help with &id tags!
php sites & cgi
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.