Question

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

My query result update register set name='m' , f_name='dsf' , l_name='dfsf' ,sellers ='Consumer' ,company='fdafa' WHERE id='3

when execute this query in sql it works fine but in my php file it gives me error Unknown column 'name' in 'field list' . I have check my column name already it is right. Meanwhile i change code placement then error is same but column name changed like Unknown column 'f_name' in 'field list'. And secondly my others queries executing successfully but not effect my data base. Also these queries are working fine in mysql.

Was it helpful?

Solution

Maybe you are using the wrong table/database in PHP?

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

Is the table in the output? If so, is the column in the next output?

echo "<pre>", var_dump( mysql_fetch_assoc( mysql_query("SHOW COLUMNS FROM register") ) ) , "</pre>"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top