Hello all,
I am trying to update a record in my database and MYSQL query but the field is not changeing
but when i mention Name and ID then the data is updating but its cant fatch data by the variable.
Ex: pudate_action.php
<?php
/* Attempt MySQL server connection. */
$link = mysqli_connect("localhost", "root", "", "maternity");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$name=$_POST['pat_name'];
// Attempt update query execution
$sql = "UPDATE patent SET pat_name='w' WHERE sl_no=10";
if(mysqli_query($link, $sql)){
echo "Records were updated successfully.";
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
But when i write this code , its change nothing:
<?php
/* Attempt MySQL server connection. */
$link = mysqli_connect("localhost", "root", "", "maternity");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$name=$_POST['pat_name'];
$id=$_POST['sl_no'];
// Attempt update query execution
$sql = "UPDATE patent SET pat_name='$name' WHERE sl_no='$id'";
if(mysqli_query($link, $sql)){
echo "Records were updated successfully.";
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
Plesase help me, from last 2 days i try a lot but i cant solve this problem
Thankyou in advance.