0
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.

Hassan Ali
  • 71
  • 1
  • 8
  • Could you directly connect to your mysql database, and edit your answer to include the output of this command: DESCRIBE register; – Cully May 10 '14 at 22:50
  • i made sure about that i m quite sure because i know error when mysql database isn't connected . – Hassan Ali May 10 '14 at 22:54
  • 1
    Note that you are **wonderfully** open to [SQL Injection](http://security.stackexchange.com/a/25710). Please use [parameterized queries](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php), or you risk having your database exported/box taken over by _automated tools_. – Clockwork-Muse May 10 '14 at 23:12
  • i think you have hint about my error . Thanks let me try it now – Hassan Ali May 10 '14 at 23:15

1 Answers1

1

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>"
Stijn Leenknegt
  • 1,317
  • 4
  • 12
  • 22
  • array (size=1) 'Tables_in_fashion' => string 'admin' (length=5) array (size=6) 'Field' => string 'id' (length=2) 'Type' => string 'int(11)' (length=7) 'Null' => string 'NO' (length=2) 'Key' => string 'PRI' (length=3) 'Default' => null 'Extra' => string 'auto_increment' (length=14) this is the result can you explain it ? – Hassan Ali May 10 '14 at 23:11
  • @HassanAli Edit your question to include this information. – Cully May 10 '14 at 23:16
  • thanks i sorted out my error and also had solved it . – Hassan Ali May 10 '14 at 23:27