gpt4 book ai didi

php - 您的 SQL 语法 'WHERE BapID=' 1/'' 第 3 行有错误

转载 作者:行者123 更新时间:2023-11-30 00:27:21 25 4
gpt4 key购买 nike

帮助。我不知道在哪里寻找错误。

这是错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 3 行“WHERE BapID”附近使用的正确语法

<?php  
$conn = mysql_connect('localhost', 'root', '');
if (!$conn)
{
die('Could not connect:' . mysql_error());
}
mysql_select_db('RMS', $conn);


$id = $_REQUEST['BapID'];

$result = mysql_query('SELECT * FROM baptism WHERE BapID');
$row = mysql_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}

$FirstName=$row['FirstName'];
$MiddleName=$row['MiddleName'];
$LastName=$row['LastName'];
$Father=$row['Father'];
$Mother=$row['Mother'];
$Datebirth=$row['Datebirth'];
$Birthplace=$row['Birthplace'];
$Datebaptism=$row['Datebaptism'];
$ministerbaptism=$row['Ministerbaptism'];
$Sponsor=$row['Sponsors'];

if(isset($_POST['save']))
{
$firstname_save = $_POST['firstname'];
$middlename_save = $_POST['middlename'];
$lastname_save = $_POST['lastname'];
$father_save= $_POST['father'];
$mother_save= $_POST['mother'];
$datebirth_save=$_POST['datebirth'];
$birthplace_save=$_POST['birthplace'];
$datebap_save=$_POST['datebaptism'];
$minister_save=$_POST['ministerbaptism'];
$sponsor_save=$_POST['sponsors'];

mysql_query("UPDATE baptism SET FirstName='$firstname_save', MiddleName='$middlename_save', LastName='lastname_save', Father='$father_save',
Mother='$mother_save', Datebirth='$datebirth_save', Birthplace='$birthplace_save',
Datebaptism='$datebap_save', Ministerbaptism='$minister_save', Sponsors='$sponsor_save', WHERE BapID")
or die(mysql_error());
echo "Updated!<br />";
echo "<a href=baptismal.php>Go back to Records</a><br />";
}
mysql_close($conn);
?>
<style>
tr
{
text-align:left;
}
#submit{
text-align:right;
}
</style>
<body>
<form method="post">
<table>
<th>First Name:</th><th><input type="text" name="firstname" value="<?php echo $FirstName; ?>"/></br></th>
<tr>
<th>Last Name:</th><th><input type="text" name="middlename" value="<?php echo $MiddleName; ?>"/></br></th>
<tr>
<th>Middle Name:</th><th><input type="text" name="lastname" value="<?php echo $LastName; ?>"/></br></th>
<tr>
<th>Father:</th><th><input type="text" name="father" placeholder="Father's Name" value="<?php echo $Father ?>"/></br></th>
</tr><tr>
<th>Mother:</th><th><input type="text" name="mother" placeholder="Mother's Name" value="<?php echo $Mother ?>"/></br></th>
</tr><tr>
<th>Date of Birth:</th><th><input type="date" name="datebirth" value="<?php echo $Datebirth ?>"/></br></th>
</tr><tr>
<th>Place of Birth:</th><th><input type="text" name="birthplace" placeholder="Place of Birth"value="<?php echo $Birthplace ?>"/></br></th>
</tr><tr>
<th>Date of Baptism:</th><th><input type="date" name="datebaptism"value="<?php echo $Datebaptism ?>"/></br></th>
</tr><tr>
<th>Minister of Baptism:</th><th><input type="text" name="ministerbaptism" placeholder="Minister"value="<?php echo $ministerbaptism ?>"/></br></th>
</tr><tr>
<th>Sponsors:</th><th><input type="text" name="sponsors" placeholder="Sponsor"value="<?php echo $Sponsor ?>"/></br></th>
</tr>
<th></th><th id=submit><input type="submit" name="save" value="Save"/></th>
</table>
</body>

最佳答案

BapID 的 = 是什么?

UPDATE baptism
SET FirstName='$firstname_save',
MiddleName='$middlename_save',
LastName='lastname_save',
Father='$father_save',
Mother='$mother_save',
Datebirth='$datebirth_save',
Birthplace='$birthplace_save',
Datebaptism='$datebap_save',
Ministerbaptism='$minister_save',
Sponsors='$sponsor_save'
WHERE BapID = ''; <<----- Add the searching value here

关于php - 您的 SQL 语法 'WHERE BapID=' 1/'' 第 3 行有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22769528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com