TRUSTINWEB Posted April 18, 2010 Share Posted April 18, 2010 TBL project creation failed ! Error :Invalid default value for 'account_id' below is the sql: CREATE TABLE `account` ( `account_id` bigint(20) NOT NULL auto_increment, `username` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`account_id`) ); CREATE TABLE `project` ( `project_id` bigint(20) NOT NULL auto_increment, `account_id` bigint(20) NOT NULL default '', `project_name` varchar(255) NOT NULL default '', `admin_email` varchar(255) NOT NULL default '', `autoresponder_email` varchar(255) NOT NULL default '', `number_of_Answers` int(11) NOT NULL default '0', `Answers` text NOT NULL, `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`project_id`) ) ; CREATE TABLE `stats` ( `project_id` bigint(20) NOT NULL default '0', `account_id` bigint(20) NOT NULL default '', `question_id` bigint(20) NOT NULL default '', `ip` bigint(20) NOT NULL default '0', `answered` int(20) NOT NULL default '0', `converted` int(20) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00' ) ; Thanks for the help TRUSTINWEB Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/ Share on other sites More sharing options...
Mchl Posted April 18, 2010 Share Posted April 18, 2010 CREATE TABLE `project` ( `project_id` bigint(20) NOT NULL auto_increment, `account_id` bigint(20) NOT NULL default '', BIGINT can't store empty string. Just do not specify default value. Why you need BIGINTs BTW? Also, instead of `create_date` datetime NOT NULL default '0000-00-00 00:00:00', you can use `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044228 Share on other sites More sharing options...
TeddyKiller Posted April 18, 2010 Share Posted April 18, 2010 id's I usually use INT(11) Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044229 Share on other sites More sharing options...
TRUSTINWEB Posted April 18, 2010 Author Share Posted April 18, 2010 [pre]Still having a 'Problem'[/pre] This is the part that is hanging up? CREATE TABLE `project` ( `project_id` bigint(20) NOT NULL auto_increment, `account_id` bigint(20) NOT NULL '', `project_name` varchar(255) NOT NULL default '', `admin_email` varchar(255) NOT NULL default '', `autoresponder_email` varchar(255) NOT NULL default '', `number_of_Answers` int(11) NOT NULL default '0', `Answers` text NOT NULL, `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`project_id`) ) ; CREATE TABLE `stats` ( `project_id` bigint(20) NOT NULL '0', `account_id` bigint(20) NOT NULL '', `question_id` bigint(20) NOT NULL '', `ip` bigint(20) NOT NULL '0', `answered` int(20) NOT NULL default '0', `converted` int(20) NOT NULL default '0', `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, ) ; So, I changed it to what was offered up here: I got rid of the default, and changed the call for the date/time. Also, I changed bigint(20) to int(11) ,but still not working?? CREATE TABLE `account` ( `account_id` int(11) NOT NULL auto_increment, `username` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`account_id`) ); CREATE TABLE `project` ( `project_id` int(11) NOT NULL auto_increment, `account_id` int(11) NOT NULL '', `project_name` varchar(255) NOT NULL default '', `admin_email` varchar(255) NOT NULL default '', `autoresponder_email` varchar(255) NOT NULL default '', `number_of_Answers` int(11) NOT NULL default '0', `Answers` text NOT NULL, `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`project_id`) ) ; CREATE TABLE `stats` ( `project_id` int(11) NOT NULL default '0', `account_id` int(11) NOT NULL '', `question_id` int(11) NOT NULL default '', `ip` bigint(20) NOT NULL default '0', `answered` int(20) NOT NULL default '0', `converted` int(20) NOT NULL default '0', `create_date` timestamp NOT NULL default CURRENT_TIMESTAMP, ) ; Could some one put the code here, so I could copy 'n paste? I would appreciate it. [pre]Thanks-- TRUSTINWEB[/pre] Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044244 Share on other sites More sharing options...
Mchl Posted April 18, 2010 Share Posted April 18, 2010 removing a word 'default' and leaving a value ( '' ) seems like a good solution? If you want ready code, I can give it to you for €20 Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044251 Share on other sites More sharing options...
TRUSTINWEB Posted April 18, 2010 Author Share Posted April 18, 2010 Nope- that didn't work either... Thanks anyways... Still unsolved.. Any more suggestions would be appreciated... TRUSTINWEB Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044258 Share on other sites More sharing options...
TeddyKiller Posted April 18, 2010 Share Posted April 18, 2010 You could always just manually create the tables in your phpmyadmin? Unless its for another reason. Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044260 Share on other sites More sharing options...
Mchl Posted April 18, 2010 Share Posted April 18, 2010 Nope- that didn't work either... Of course it didn't work. This is what you did, and that's what causing an error. CREATE TABLE `project` ( `project_id` int(11) NOT NULL auto_increment, `account_id` int(11) NOT NULL, ... CREATE TABLE `stats` ( `project_id` int(11) NOT NULL default 0, `account_id` int(11) NOT NULL, `question_id` int(11) NOT NULL, Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044263 Share on other sites More sharing options...
TRUSTINWEB Posted April 18, 2010 Author Share Posted April 18, 2010 Okay- I got it to work by using the following below: [pre]but I still get an error message:? ERROR CREATE PROJECT :Unknown column 'number_of_questions' in 'field list'[/pre] this is what I have now: CREATE TABLE `account` ( `account_id` int(20) NOT NULL auto_increment, `username` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`account_id`) );# MySQL returned an empty result set (i.e. zero rows). CREATE TABLE `project` ( `project_id` int(20) NOT NULL auto_increment, `account_id` int(20) NOT NULL default '0', `project_name` varchar(255) NOT NULL default '', `admin_email` varchar(255) NOT NULL default '', `autoresponder_email` varchar(255) NOT NULL default '', `number_of_Answers` int(11) NOT NULL default '0', `Answers` text NOT NULL, `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`project_id`) ) ;# MySQL returned an empty result set (i.e. zero rows). CREATE TABLE `stats` ( `project_id` int(20) NOT NULL default '0', `account_id` int(20) NOT NULL default '0', `question_id` int(20) NOT NULL default '0', `ip` bigint(20) NOT NULL default '0', `answered` int(20) NOT NULL default '0', `converted` int(20) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00' ) ;# MySQL returned an empty result set (i.e. zero rows). Thanks- Again.. TRUSTINWEB Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044338 Share on other sites More sharing options...
TRUSTINWEB Posted April 18, 2010 Author Share Posted April 18, 2010 I figured it out--- Thanks for the help... Thanks for pointing me in the right direction>>!!!! This was the magic code... <? require_once 'config.php'; $connection = mysql_pconnect("$dbhost", "$dbusername", "$dbpasswd"); $db = mysql_select_db("$database_name", $connection) or die("Couldn't select database."); $table0 = mysql_query("CREATE TABLE `account` ( `account_id` bigint(20) NOT NULL auto_increment, `username` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`account_id`) )"); if($table0) { }else{ echo "TBL account creation failed !<br>"; echo "Error :".mysql_error()."<br>"; exit(); } $table1 = mysql_query("CREATE TABLE `project` ( `project_id` int(20) NOT NULL auto_increment, `account_id` int(20) NOT NULL, `project_name` varchar(255) NOT NULL default '', `admin_email` varchar(255) NOT NULL default '', `autoresponder_email` varchar(255) NOT NULL default '', `number_of_questions` int(11) NOT NULL default '0', `questions` text NOT NULL, `create_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`project_id`) )"); if($table1) { }else{ echo "TBL project creation failed !<br>"; echo "Error :".mysql_error()."<br>"; exit(); } $table2 = mysql_query("CREATE TABLE `stats` ( `project_id` int(20) NOT NULL default '0', `account_id` int(20) NOT NULL, `question_id` int(20) NOT NULL, `ip` int(20) NOT NULL default '0', `answered` int(20) NOT NULL default '0', `converted` int(20) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00' )"); if($table2) { }else{ echo "TBL stats creation failed !<br>"; echo "Error :".mysql_error()."<br>"; exit(); } TRUSTINWEB mysql_close($connection); echo "<br>Installation Successful <br>"; echo "<br>Click <a href=login.php>Here To Proceed To Login Page</a><br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/#findComment-1044362 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.