I am tring to update data of private_tutor Table. But its not working . But when I write the sql command
(UPDATE private_tutor SET name='private' , contact_number='0000' ,
address='dw', experience='s',
qualification='dwd' , age='dwd', about='dwd'
WHERE id=1)
in terminal it updates , table.
What may be the reason , I am giving the same query through php. why its not working ?
output
UPDATE private_tutor SET name='private' , contact_number='0000' , address='dw', experience='s', qualification='dwd' , age='dwd', about='dwd' WHERE id=1
There is some problem in adding record
update.php
<?php //start php tag
//include connect.php page for database connection
include('connect.php');
include('session.php');
//if submit is not blanked i.e. it is clicked.
Echo $_GET['profile-name'].$_GET['profile-contact'].$_GET['address'].$_GET['experience'].$_GET['qualification'].$_GET['age'].$_GET['about'].$_GET['id'];
If(isset($_GET['submit']))
{
$sql="UPDATE private_tutor
SET name='".$_GET['profile-name']."' ,
contact_number='".$_GET['profile-contact']."' ,
address='".$_GET['address']."',
experience='".$_GET['experience']."',
qualification='".$_GET['qualification']."' ,
age='".$_GET['age']."',
about='".$_GET['about']."'
WHERE id=".$_GET['id']." ";
echo "</br>".$sql."</br>";
$res=$conn->query($sql);
If($res)
{
header('Location:private-tutor-profile.php');
}
Else
{
Echo "There is some problem in adding record";
}
}
?>
Instead of outputting your own error message which tells you next to nothing about the problem, output the error message from the database connection.
So instead of this line
Echo "There is some problem in adding record";
Do this instead:
If $conn
is PDO
echo print_r( $conn->error_info );
If $conn
is MYSQLI_
echo $conn->error;
But quite possibly, your connection has failed and you do not show us that code!! And I assume you are not looking for error messages there either.