大家好我正在尝试应用此查询但值不会保存在我的数据库中。我已经尝试了很多,但我无法解决它。请帮我。提前致谢
if($_POST) {
$lecturer_id = $_SESSION["lecturer_id"];
$game_name= $_POST['game_name'];
mysql_query("insert into games(game_name, lecturer_id) values ('$game_name', '$lecturer_id')");
$input_type = $_POST['type'];
if($input_type=='multiple_choice') {
$question= $_POST['quest'];
$val1= $_POST['value1'];
$val2= $_POST['value2'];
$val3= $_POST['value3'];
$val4= $_POST['value4'];
//echo $question;
// echo $val4;
mysql_query("insert into subgames(game_id, input_id, statement, option1, option2, option3, option4) values ((SELECT id
FROM games
WHERE game_name = '$game_name'), '$input_type', '$question', '$val1', '$val2', '$val3', '$val4'");
} elseif($input_type=='input_field') {
$question= $_POST['quest'];
$answer= $_POST['ans'];
}
} else {
echo "Not Submitted";
}
答案 0 :(得分:0)
您是否尝试检查mysql_error()?
添加此代码:
echo mysql_error();
然后发布错误。
答案 1 :(得分:0)
Step 1:-
SHOW CREATE TABLE table_name:
It will show table details
| table_name | CREATE TABLE `table_name` (
`id` int(20) unsigned NOT NULL auto_increment,
`key_column` smallint(5) unsigned default '1',
KEY `key_column` (`key_column`),
CONSTRAINT `table_name_ibfk_1` FOREIGN KEY (`key_column`) REFERENCES
`second_table` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
Step2:-
ALTER TABLE table_name DROP KEY `key_column`;
Step3:-
ALTER TABLE table_name DROP FOREIGN KEY `table_name_ibfk_1`;