我对我的PHP代码有疑问:
$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, "%Y.%m.%d"), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");
仔细看看:
FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, "%Y.%m.%d")
带有%符号的字符会给我这个语法错误:
Parse error: syntax error, unexpected '%' in C:\wamp\www\ayarabasla.php on line 4
我是如何使用%符号编写查询的?
答案 0 :(得分:4)
语法高亮显示器显示您的错误。这是一个报价问题。逃避你的内在双引号:
$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, \"%Y.%m.%d\"), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");
您也可以使用单引号:
$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, '%Y.%m.%d'), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");