i Create a MySQL database and i include sql table thene he give me this error can any one help me what wrong with this table Erreur requête SQL: -- -------------------------------------------------------- -- -- Table structure for table `cached` -- CREATE TABLE `cached` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT , `listingid` int( 11 ) NOT NULL default '', `url` char( 200 ) NOT NULL default '', `html` text NOT NULL , `createDate` datetime NOT NULL default '0000-00-00 00:00:00', `modifyDate` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY ( `id` ) ) MySQL a répondu:Documentation #1067 - Invalid default value for 'listingid' PHP:
I wouldn't even list a default value if you don't have one. However, you have the listingid, url and html as "NOT NULL" but you are giving them null values. You have to have some sort of default value.
The reason it doesn't work is that you are assigning a default varchar ('' is a string) to an integer value (listingid)
No that part is correct, '' is an empty string but not the same as NULL so it is a valid default for a NOT NULL column. The issue is with the default type (string in a int column)
Change: `listingid` int( 11 ) NOT NULL default '', Code (markup): To: `listingid` int( 11 ) NOT NULL default 0, Code (markup):
the reason that changing the '' to a 0 worked is because you explicitly told mysql that the data type for listingid is an integer and then you're trying to default it to a string.