0

我一直在尝试编写代码以插入不同的表,但它在第 23 行一直给我错误。

这是一个大学项目登记表。

<?php

$con = mysql_connect(","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("HNDGeorgeMason", $con);

$firstname=$_POST['firstname'];
$surname=$_POST['surname'];
$username=$_POST['username'];
$password=$_POST['password'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
$userid=$_POST['userid'];
$type=$_POST['type'];

switch ($_POST['type'])
{
case guides
 $sql="INSERT INTO Guides (firstname, surname, type, username, password)
 VALUES ('$firstname', '$surname', '$type', '$username', '$password')";

case parents
 $sql="INSERT INTO Parents (firstname, surn ame, type, username, password)
VALUES ('$firstname', '$surname', '$type', '$username', '$password')"; 

case leaders
 $sql="INSERT INTO Leaders (firstname, surname, type, username, password)
 VALUES ('$firstname', '$surname', '$type', '$username', '$password')"; 
}

 mysql_close($con);
?>
4

2 回答 2

2

检查您的代码

于 2012-11-07T15:56:45.913 回答
1
case "leaders":
 $sql="INSERT INTO Leaders (firstname, surname, type, username, password)
 VALUES ('$firstname', '$surname', '$type', '$username', '$password')"; 
break;
于 2012-11-07T15:58:04.303 回答