FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

SQL table troubles.

 


ALostSoul
Why don't these two tables work?

-----------------------------------------------------------------------------------------

1.

CREATE TABLE `news` (
`id` int(10) unsigned NOT NULL auto_increment,
`postdate` timestamp NULL default NULL,
`title` varchar(50) NOT NULL default '',
`newstext` text NOT NULL,
PRIMARY KEY (`id`),
KEY `postdate` (`postdate`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

-----------------------------------------------------------------------------------------

2.

CREATE TABLE `news_comments` (
`id` int(10) unsigned NOT NULL auto_increment,
`news_id` int(10) unsigned NOT NULL default '0',
`name` varchar(40) NOT NULL default '',
`comment` text NOT NULL,
PRIMARY KEY (`id`),
KEY `news_id` (`news_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

--------------------------------------------------------------------------------------

Help?
hexkid
They work for me.
ALostSoul and MySQL wrote:
Code:
~$ mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12279 to server version: 4.1.10-Debian_4-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> CREATE TABLE `news` (
    -> `id` int(10) unsigned NOT NULL auto_increment,
    -> `postdate` timestamp NULL default NULL,
    -> `title` varchar(50) NOT NULL default '',
    -> `newstext` text NOT NULL,
    -> PRIMARY KEY (`id`),
    -> KEY `postdate` (`postdate`)
    -> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE `news_comments` (
    -> `id` int(10) unsigned NOT NULL auto_increment,
    -> `news_id` int(10) unsigned NOT NULL default '0',
    -> `name` varchar(40) NOT NULL default '',
    -> `comment` text NOT NULL,
    -> PRIMARY KEY (`id`),
    -> KEY `news_id` (`news_id`)
    -> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
Query OK, 0 rows affected (0.00 sec)

mysql> insert news values (null, null, 'title', 'newstext');
Query OK, 1 row affected (0.00 sec)

mysql> insert news_comments values (null, 1, 'name', 'comment');
Query OK, 1 row affected (0.01 sec)

mysql> select * from news;
+----+----------+-------+----------+
| id | postdate | title | newstext |
+----+----------+-------+----------+
| 10 |     NULL | title | newstext |
+----+----------+-------+----------+
1 row in set (0.00 sec)

mysql> select * from news_comments;
+----+---------+------+---------+
| id | news_id | name | comment |
+----+---------+------+---------+
| 14 |       1 | name | comment |
+----+---------+------+---------+
1 row in set (0.00 sec)

mysql> drop table news;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table news_comments;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
~$
Bye
ALostSoul
That's odd, because in phpMyAdmin they refuse to work.
Rhysige
try removing DEFAULT CHARSET=latin1 from both the querys
ALostSoul
Rhysige wrote:
try removing DEFAULT CHARSET=latin1 from both the querys



yeah, i got them working before this. thanks anyways.
soulman
oh I need a help that tables are created by PHP script after the PHP file checked there is no table with same table name exists...
Rhysige
you what?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.