未知列'名称'在'字段列表'

时间:2014-05-10 22:38:10

标签: php mysql sql updates

if(isset($_REQUEST['action_t']))
{

    $gender=$_REQUEST['gender'];
    $firstname=$_REQUEST['firstname'];
    $lastname=$_REQUEST['lastname'];
    $sellers=$_REQUEST['sellers'];
    $company=$_REQUEST['company'];


    echo $query=" update register set `name`='$gender' , `f_name`='$firstname' , `l_name`='$lastname' ,`sellers` ='$sellers' ,`company`='$company' WHERE id='$id'";
    mysql_query($query) or die(mysql_error());
    //die();
    echo "<script>alert('You have successfully Updated Your account') </script>";
}
if(isset($_REQUEST['action_p']))
{

    $existing_password=$_REQUEST['existing_password'];
    $npassword=$_REQUEST['npassword'];
    $w=mysql_query("select password from register where id='$id'");
    $ro=mysql_fetch_array($w);
    $password=$ro['password'];
    if($existing_password==$password)
    {
    echo $queryi="UPDATE `register` SET `password`='$npassword' WHERE id='$id'";
    mysql_query($queryi)or die(mysql_error());
    echo "<script>alert('You have successfully Updated Password') </script>";
    }
    else 
    echo "<script>alert('You have Enter Wrong Password') </script>";
}
if(isset($_REQUEST['action_e']))
{

    $email=$_REQUEST['email'];
    $existing_password=$_REQUEST['existing_password'];
    $w=mysql_query("select password from register where id='$id'");
    $ro=mysql_fetch_array($w);
    $password=$ro['password'];
    if($existing_password==$password)
    {
    echo $querye="UPDATE `register` SET `email`='$email' WHERE id='$id'";
    mysql_query($querye)or die(mysql_error());
    echo "<script>alert('You have successfully Updated Email') </script>";
    }
    else 
     echo "<script>alert('You have Enter Wrong Password') </script>";
}
 ?>

我的查询结果 更新寄存器集name ='m',f_name ='dsf',l_name ='dfsf',sellers ='消费者',company =' fdafa'WHERI id ='3

在sql中执行此查询时,它工作正常,但在我的php文件中,它在“字段列表”中给出了错误未知列'name'。我已经检查了我的专栏名称是否正确。同时我更改代码放置然后错误是相同的但列名称改变了 “字段列表”中的未知列'f_name'。其次,我的其他人查询成功执行但不影响我的数据库。这些查询在mysql中运行正常。

1 个答案:

答案 0 :(得分:1)

也许您在PHP中使用了错误的表/数据库?

echo "<pre>", var_dump( mysql_fetch_assoc( mysql_query("SHOW TABLES") ) ) , "</pre>"

表格在输出中吗?如果是,那么下一个输出中的列是什么?

echo "<pre>", var_dump( mysql_fetch_assoc( mysql_query("SHOW COLUMNS FROM register") ) ) , "</pre>"