你的变量没有被解析,不信,你把sql echo出来看看就知道了!
$sql="INSERT INTO mycourse SELECT * FROM course WHERE grade = '$grade' AND name = '$name'";
变成
$sql="INSERT INTO mycourse SELECT * FROM course WHERE grade = '{$grade}' AND name = '{$name}'";
试试
你的SQL语句写错了 你是要插入数据还是查询数据