xProteuSx Posted November 13, 2006 Share Posted November 13, 2006 I am very new to php/MySQL so I am playing around with the basic functions and I cannot get the DROP TABLE statement to work. My code is as follows:[code]<?php$sql = "DROP TABLE usersCREATE TABLE users (users_id int(6) NOT NULL auto_increment,users_handle varchar(20) default NULL,users_password varchar (20) default NULL,users_email varchar (40) default NULL,users_datejoined timestamp NOT NULL,users_visits int (6) default '0',users_lastvisit timestamp NOT NULL,users_questionsanswered int(6) default '0',users_correctanswers int(6) default '0',users_percentcorrect float default '0',users_totalscore int (6) default '0',users_pagesviewed int(8) default '0',users_visitbonus int(6) default '0',users_activity int(6) default '0',PRIMARY KEY(users_id),UNIQUE(users_handle)) TYPE=MYISAM;"?>[/code]I tried everything I can think of, I believe, including [font=Verdana]"DROP TABLE users;"[/font] I don't know what to do anymore. Some help would be duly appreciated. Thanks guys. Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted November 13, 2006 Author Share Posted November 13, 2006 I should mention that what I am trying to do is the DROP the previous 'users' table, and create a new one in its place. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 15, 2006 Share Posted November 15, 2006 Well, all you need is "DROP TABLE users"... what error are you getting back? Maybe it's a permission issue? Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted November 15, 2006 Author Share Posted November 15, 2006 fenway, thanks for the reply but I have solved the problem by adding the following code just above the clause which calls for the creation of the table:[code]$sql1 = "DROP TABLE IF EXISTS users";$result1 = MYSQL_QUERY($sql1);if (!$result1){print mysql_error();}[/code]Sadly, I am unsure as to why this worked, but it did. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 15, 2006 Share Posted November 15, 2006 It worked because you had already dropped this table at some point, so the DROP TABLE call was returning an error of "unknown table". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.