Forum Moderators: coopster
CREATE TABLE `company` (
`c_id` bigint(20) NOT NULL auto_increment,
`c_name` varchar(255) NOT NULL,
`cat_id` bigint(20) NOT NULL,
PRIMARY KEY (`c_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
CREATE TABLE `message` (
`m_id` bigint(20) NOT NULL auto_increment,
`mobile_no` varchar(100) NOT NULL,
`s_message` longtext NOT NULL,
`p_id` bigint(255) NOT NULL,
`c_id` bigint(20) NOT NULL,
`list_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`m_id`),
KEY `c_id` (`c_id`),
KEY `p_id` (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE `prefix` (
`p_id` bigint(20) NOT NULL auto_increment,
`c_abbrev` varchar(100) NOT NULL,
`c_id` bigint(20) NOT NULL default '0',
PRIMARY KEY (`p_id`),
UNIQUE KEY `c_abbrev` (`c_abbrev`),
KEY `c_id` (`c_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
I want to insert into the message table but still be able to store the two foreign keys c_id and p_id into the table
The code am using is
s_message = $_POST['s_message'];
$message_prefix = $_POST['message_prefix'];
$mobile_no = $_POST['mobile_no'];
$message_id = $_POST['message_id'];
$result = mysql_query ("INSERT INTO `message` ( `m_id` ,`list_time`,`mobile_no`,`p_id`,`s_message` ) VALUES ('',current_timestamp,'$mobile_no','$p_id','$s_message')
");
if (!$result)
die ('Invalid query: ' . mysql_error());
echo "<strong>Success! Thank you Your Message has been received.</strong>";
echo "<strong>Thank you and Welcome Again </strong>";
}
Please help