xProteuSx Posted November 9, 2006 Share Posted November 9, 2006 The following is a snippet of code where I try to make a DB table. I don't know how to troubleshoot table creation. I am not getting any MySQL errors, but the table is not being created either. Please help! I have stayed up all night trying to figure this out ...[code]<!-- connect to MySQL --><?php$dbh=mysql_connect ("$serverurl", "$databasename", "$passofuser") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("$databasename");?><!--create MySQL Table --><?php$sql = "DROP TABLE IF EXISTS 'users';CREATE 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 (3,2) default '0','users_totalscore' 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] Quote Link to comment https://forums.phpfreaks.com/topic/26734-cannot-create-mysql-table/ Share on other sites More sharing options...
blear Posted November 9, 2006 Share Posted November 9, 2006 [code]DROP TABLE IF EXISTS users;CREATE 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 (3,2) 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]Take out ALL the single quotes, add a datatype to users_totalscore. The code I posted worked on my MySQL db. Quote Link to comment https://forums.phpfreaks.com/topic/26734-cannot-create-mysql-table/#findComment-122283 Share on other sites More sharing options...
xProteuSx Posted November 10, 2006 Author Share Posted November 10, 2006 Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/26734-cannot-create-mysql-table/#findComment-122495 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.