根据我上面的问题。我不知道为什么会发生此错误。当我将PHP文件放置到XAMPP时,一切正常。但是,当我将其放置到SQL Server时,就会出现此错误。当我想向数据库中插入数据时发生此错误。下面是我的代码:
require_once "../../../config/configPDO.php";
require_once "../../../config/check.php";
if(isset($_POST['Submit']))
{
//Getting Post Values
$engineer_badgeid = $_POST['engineer_badgeid'];
// Query for validation of username and email-id
$ret="SELECT * FROM team where (engineer_badgeid=:engineer_badgeid)";
$queryt = $conn -> prepare($ret);
$queryt->bindParam(':engineer_badgeid',$engineer_badgeid,PDO::PARAM_STR);
$queryt -> execute();
$results = $queryt -> fetchAll(PDO::FETCH_OBJ);
if($queryt -> rowCount() == 0)
{
$sql="INSERT INTO team (team_name, engineer_badgeid) SELECT fullname, badgeid FROM users WHERE users.badgeid = '$engineer_badgeid'";
$query = $conn->prepare($sql);
// Binding Post Values
$query->bindParam('engineer_badgeid', $engineer_badgeid);
$query->execute();
if($query->rowCount() > 0 ){
header("Location:team.php");
}else{
echo "
<script>alert('Something wrong, please try again')</script>
<script>window.location = 'team.php'</script>
";
}
}
else{
echo "
<script>alert('The team you want to add is already exist')</script>
<script>window.location = 'team.php'</script>
";
}
}
?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。