-3
  1. $abc = mysql_fetch_array($result);
      if (!$result)
         die("Error: Data not found..");        
    
    $name=$abc['name'] ;
    $email= $abc['email'] ;                 
    
    
    $sql = "UPDATE example SET name ='$name', email ='$email' WHERE id = '$id'";
        if(mysql_query($con, $sql)) //Error
            Echo "Record Update successfully";
        else
            Echo "ERROR: could not able to execute $sql".mysql_error($con); 
    
    mysql_close($con);
    
Insane Skull
  • 9,220
  • 9
  • 44
  • 63

4 Answers4

2

Update your code in this way :

$sql = "UPDATE example SET name = $name,email = $email WHERE id = $id";
mysql_query($sql,$con);
RK12
  • 472
  • 3
  • 11
0

You need to swap the $con and $que paramters in your mysql_query function.

http://php.net/manual/en/function.mysql-query.php

0

you must replace $sql with $con

if(mysql_query($sql, $con))
       {
        Echo "Record Update successfully";
       } 
       else
       {
        Echo "ERROR: could not able to execute $sql".mysql_error($con);
       }
0

you may use mysqli instead, which is the new version of mysql with more security features, but you have to unit all the code to use either mysql or mysqli

mysqli_query($connection,$query);

OR

mysql_query($query,$connection);

whenever you use the mysqli, you should set parameter 1 to be the connection resource

Akram Qalalwa
  • 103
  • 11