How to update date in mysql -
my code looks this
<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("library", $con); $colid = $_post['data']; $count = count($colid); $curdate = date('y-m-d'); for($i=0;$i<$count;$i++){ $tsql ="update transaction set return=$curdate status='1' tid = $colid[$i] "; $tresult = mysql_query($tsql); } if(! $tresult ) { die('could not enter data: ' . mysql_error()); } echo "deleted book successfully\n"; mysql_close($con); ?>
and error
could not enter data: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'return=2014-04-21 status='1' tid = 1' @ line 2
my requirement when ever got clicked button need execute code
i tried using curdate()
function getting same error
any appreciated
return mysql reserved keyword need wrap back-ticks,and missing comma
before status pointed @user3414693
update transaction set `return`=curdate(), status='1' tid = $colid[$i]
Comments
Post a Comment