Jump to content

Creating table


SUNIL16

Recommended Posts

Hi Friends,

 

Below is my code for creating table

mysql_query("CREATE TABLE `table1` (
`topicid` int(5) NOT NULL auto_increment,
`topic` varchar(255) NOT NULL default'0',
`detail` longtext NOT NULL,
`memberid` int(5) NOT NULL default '0',
`datetime` varchar(25) NOT NULL default'0',
`view` int(4) NOT NULL default '0',
`reply` int(4) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ");


mysql_query("CREATE TABLE `table2` (
`topics_id` int(4) NOT NULL default '0',
`a_id` int(4) NOT NULL default '0',
`a_memberid` int(5) NOT NULL default '0',
`a_answer` longtext NOT NULL,
`a_datetime` varchar(25) NOT NULL default '0',
KEY `a_id` (`a_id`)
) TYPE=MyISAM;");

 

I able create only 2nd table... Please tell me y its not creating table1.. i am not getting where is the error...

Link to comment
https://forums.phpfreaks.com/topic/133904-creating-table/
Share on other sites

Try putting some traps for errors:

<?php
$result = mysql_query("CREATE TABLE `table1` (
`topicid` int(5) NOT NULL auto_increment,
`topic` varchar(255) NOT NULL default'0',
`detail` longtext NOT NULL,
`memberid` int(5) NOT NULL default '0',
`datetime` varchar(25) NOT NULL default'0',
`view` int(4) NOT NULL default '0',
`reply` int(4) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}


$result = mysql_query("CREATE TABLE `table2` (
`topics_id` int(4) NOT NULL default '0',
`a_id` int(4) NOT NULL default '0',
`a_memberid` int(5) NOT NULL default '0',
`a_answer` longtext NOT NULL,
`a_datetime` varchar(25) NOT NULL default '0',
KEY `a_id` (`a_id`)
) TYPE=MyISAM;");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/133904-creating-table/#findComment-697059
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.