douqiang1910 2013-04-17 04:24
浏览 6
已采纳

too long

I am trying to update record in table by getting an id from another .php file..But it can't update .Please help. Here is my code.

<?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);
}


?>
  • 写回答

1条回答 默认 最新

  • dongweiben5229 2013-04-17 04:26
    关注

    here you have two SET and because of that query was failing and also you forgot , before phone = {

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

    should be

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

    EDIT

    write this to check the error

    mysql_query($insert) OR die(mysql_error());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?