我想知道是否可以让某人查看我的陈述,看看我可能在哪里搞砸了。我已经通过回显它测试了正在发布的信息,并且一切似乎都在正确地进行,但我无法让它物理地创建适当的记录。我也没有收到任何错误,它会像表单发布的那样返回到标题位置。
//First we make sure there are enough licenses left to add the user
$limit = "select * from organization_seats WHERE orgid=$orgid";
$orglimit = mysql_query($limit);
$licenses = $orglimit['limit'];
$count = "select count(*) from organization_users WHERE organizationid=$orgid";
if ((!$licenses < $count)) {
echo 'You have reached the number of maximum licenses for your Organization.';
} else {
//If we have licenses left, proceed to add new user
//Populate the user table
$sql = "insert into user (firstname, lastname, title, address1, address2, country, city, state, zip, phone, mobile, birthday, username, email, password) values ('$fname','$lname','$title','$address1','$address2','$country', '$city', '$state', '$zip', '$phone', '$mobile', '$bday', '$username', '$email', '$password')";
$exec = mysql_query($sql);
//Add the user to the organization
$userid = mysql_insert_id(); //call the last ID entered into the user table first
$sql2 = "insert into organization_users(organizationid, userid, active) values ('$orgid', '$userid', $)";
$exec = mysql_query($sql2);
//recall the userid
$sql3 = "select * from user where username = $username";
$exec = mysql_query($sql3);
$newuserid = $newuserselect['id'];
//Add the user to the department
$sql4 = "insert into organization_dep_users(orgid, depid, userid) values ('$orgid', '$department', '$newuserid')";
$exec = mysql_query($sql4);
if ($exec === TRUE) {
header( 'Location: index.php' ) ;
} else {
echo mysql_error();
}
}
顺便说一句,我的所有变量都附加了 mysql_real_escape_string。