Here is my first UPDATE query in which i am updating the date, but it is not happening. I made sure that the query is not successful by checking the no of updated rows.
$ddline = $_POST['deadline_sem'];
$ex=explode('T', $ddline);
$date="$ex[0] $ex[1]";
$deadline=date("Y-m-d H:i:s",strtotime($date));
echo $deadline;
$qry1="UPDATE admin SET RegDeadline='$deadline' where username='root'";
if(mysql_affected_rows()>=0)
echo "Success";
else
echo "Unsuccesull";
Possible way why your code is not working
1) No database connection code.
2) Missing execute statement mysql_query($qry1);
Your code is open for sql injection
Use mysql_real_escape_string()
before update into database.
$deadline=mysql_real_escape_string($deadline);
$qry1="UPDATE admin SET RegDeadline='$deadline' where username='root'";
mysql_query($qry1);// execute statement
if(mysql_affected_rows()>=0)
echo "Success";
else
echo "Unsuccesull";
Note:- mysql is deprecated instead use PDO or mysqli
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.