Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/198937-error-message-on-table-in-sql/
Share on other sites

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,

[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]

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,

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

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>";

 

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.