I'm working on something at the minute but I need it to let people empty the database table without having any access to phpmyadmin or anything. I was thinking something along the lines of the following in a emptytable.php file should work but it doesn't seem to.
PHP Code:
<?php
$usr = "username";
$pwd = "password";
$db = "database_name";
$host = "localhost";
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
{
# setup SQL statement
$sql = 'TRUNCATE TABLE `tablename`';
# execute SQL statement
$rs = mysql_query($sql, $cid);
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
print "Table Emptied";
}
?>
This doesn't seem to actually do anything and even if it did I don't know how secure it'd be so I was hoping someone could help out.
Thanks.