无法更新表中的值
我可以请求您帮助解决我的代码中的问题吗?我有这个 update_client.php 作为我的功能来更新我的 edit.php 页面中的详细信息。
但当我单击“保存”时,它不会更改该值。我想知道我哪里做错了。有人可以帮我吗?我真的很感激。谢谢
这是我的 update_client.php 的代码
<?php
session_start();
if (!isset($_SESSION['user'])){
header("location:../efeedback/login2.php");
}
require_once "connect_to_mysql.php";
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$client_user = $_POST['client_user'];
$client_pass = $_POST['client_pass'];
$initials = $_POST['initials'];
$sql="UPDATE client_users SET name = '$name', company = '$company', email = '$email', client_user = '$client_user', client_pass = '$client_pass', initials = '$initials' WHERE id = '$id'";
$result=mysql_query($sql);
// if successfully updated.
if($result){
header("location:add_client.php");
}
else {
echo "ERROR";
}
?>
Can i ask for your help with my problem in my code. i have this update_client.php as my function to update the details in my edit.php page.
but as i click on save it doesn't change the value. I wonder where did i go wrong. can somebody please help me with it. I would really appreciate it. Thank
here is the code for my update_client.php
<?php
session_start();
if (!isset($_SESSION['user'])){
header("location:../efeedback/login2.php");
}
require_once "connect_to_mysql.php";
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$client_user = $_POST['client_user'];
$client_pass = $_POST['client_pass'];
$initials = $_POST['initials'];
$sql="UPDATE client_users SET name = '$name', company = '$company', email = '$email', client_user = '$client_user', client_pass = '$client_pass', initials = '$initials' WHERE id = '$id'";
$result=mysql_query($sql);
// if successfully updated.
if($result){
header("location:add_client.php");
}
else {
echo "ERROR";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从它的外观来看,您忘记设置 $id 变量的值
By the looks of it, you forgot to set value for $id variable
您似乎尚未设置
id
的值Seems you haven't set value for
id
您需要为
$id
设置值如果表中的字段
id
是数字类型,您需要执行以下操作:只需
$id
而不是'$id'
。You need set value for
$id
If field
id
in your table is type number, you need do this:Just
$id
not'$id'
.您始终必须阅读错误消息。在此脚本中,您给出了未定义的变量 id。
Always you have to read your error message. in this script you given Undefined variable id.