Problems with deleteing a row and a table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
HomerTheDragoon
Forum Newbie
Posts: 21
Joined: Sat Jul 08, 2006 2:10 am

Problems with deleteing a row and a table

Post by HomerTheDragoon »

Code: Select all

///remove clan///
if ($mode=="suremoveclan" && is_admin($admin)){

$clan=$_POST['clan'];
$division=$_POST['division'];
$query="DELETE FROM leaguestats_clan_$division WHERE clantag='$clan'";
mysql_query($query);
$query2="DROP TABLE leaguestats_$clan";
mysql_query($query2);
}///end remove clan///
Not sure whats wrong with either of them, but they dont work.
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Add some error handling, display the exact query being sent to the database, e.g.

Code: Select all

// are you sure these values are correct and the code block is executed at all?
// note a slight change in your conditional, just my preference
if ( ($mode=="suremoveclan") && is_admin($admin) ){
    // are you certain these POST vars exist and are valid?
    // use var_dump($_POST) in your script someplace
    $clan=$_POST['clan'];
    $division=$_POST['division'];

    $query="DELETE FROM leaguestats_clan_$division WHERE clantag='$clan'";

    mysql_query($query)
        OR die("Query 1 error:<br />{$query}<br />" .mysql_error());

    // does your user have permission to drop the table?    
    $query2="DROP TABLE leaguestats_$clan";
    
    mysql_query($query2)
        OR die("Query 2 error:<br />{$query2}<br />" .mysql_error());

}
Post Reply