Web Hosting Talk







View Full Version : TRUNCATE Script


csrs
12-06-2005, 09:53 PM
Hello . I am looking for the best way to make a simple script so that I can TRUNCATE one table in our database and seem to be having some issues getting anything to work . I have tried the following code , however, it does not work
<?php


$dbms = 'mysql';

$dbhost = 'localhost';
$dbname = 'xxxxxxxx';
$dbuser = 'xxxxxxxxx';
$dbpasswd = 'xxxxxxxx';

$db->query("TRUNCATE cust_sponsors;")

?>

To sum it up , the old webmaster had made a custom sponsor page and I need to delete the current sponsors so that I can add the new ones . This said, the script is now off the server and Iam having a hard time with getting anything done . I would really just like to delete the current sponsors by their id if this is possible. Any help would be greatly appreciated ..

Burhan
12-07-2005, 03:38 AM
If there is only one table that holds all sponsor information, and it is not linked with any other tables, then you just do DELETE FROM `cust_sponsors` and it will empty the table.

However, if the records are linked to any other tables, you will also have to delete the other references, otherwise you'll have null relationships.

csrs
12-07-2005, 12:20 PM
Thanks , I 'll give that a shot in a bit . Off topic here , the web host that is hosting this site has like disappeared and they let their cpanel license expire . It was a friend of a friend that had a server blah blah blah if ya know what I mean. Now, my question is , could another host just do a cpanel to cpanel move with the current license being expired ? The ftp server and all that still works so I was thinking they could and just grab all the wrappers and such ?

Burhan
12-07-2005, 12:47 PM
Probably, but I'm not a cpanel expert. You can always do a 'manual' move by creating a dump and then downloading + uploading + populating the database.

csrs
12-07-2005, 01:29 PM
I can't get into phpmyadmin to do the dump because the cpanel license has expired .

syberdave
12-09-2005, 01:24 AM
The syntax is TRUNCATE TABLE tablename.

$db->query("TRUNCATE TABLE cust_sponsors;");

arkin
12-09-2005, 03:25 AM
Download and run phpmyadmin without cpanel being attached to it?