$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);
Asked
Active
Viewed 3,670 times
-3

Insane Skull
- 9,220
- 9
- 44
- 63

Vrajesh Savaliya
- 3
- 1
- 4
-
mysql_query() expects parameter 1 to be string, resource given //this is error – Vrajesh Savaliya Jan 09 '16 at 11:17
-
`mysql_query($sql,$con)` – Saeed M. Jan 09 '16 at 11:18
-
1 error solve thnks, & another error = could not able to execute UPDATE example SET name ='', email ='' WHERE id = '19'Table 'test.example' doesn't exist – Vrajesh Savaliya Jan 09 '16 at 11:22
-
Welcome to Stack Overflow! Please see [ask] and [The perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) – Rizier123 Jan 09 '16 at 13:00
4 Answers
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 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);
}

Akabr Amani
- 13
- 6
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