-1

我正在尝试通过从另一个 .php 文件中获取 id 来更新表中的记录。但它无法更新。请帮忙。这是我的代码。

<?php
include('connection.php');
$member_id = $_GET['id']; 
echo ("You are going to edit/update record of employee with id #");echo $member_id;

if(isset($_REQUEST['submit']))
{
    $firstname =$_REQUEST['firstname'];
    $lastname =$_REQUEST['lastname'];
    $phone =$_REQUEST['phone'];    
    $insert = "update emp set SET firstname ={'$firstname'}, lastname = {'$lastname'} phone = {'$phone'} WHERE id = {'$member_id'}";
    mysql_query($insert);
}


?>
4

1 回答 1

2

在这里你有两个,因为那个查询失败了,你之前SET也忘记了,phone = {

$insert = "update emp set SET firstname ={'$firstname'}, lastname = {'$lastname'} phone = {'$phone'} WHERE id = {'$member_id'}";

应该

$insert = "update emp SET firstname ={'$firstname'}, lastname = {'$lastname'}, phone = {'$phone'} WHERE id = {'$member_id'}";

编辑

写这个来检查错误

mysql_query($insert) OR die(mysql_error());
于 2013-04-17T04:26:29.340 回答