php遇到一个格式不正确的数值


A non well formed numeric value encountered php

我正在从数据库传递日期并设置dateforService的值,然后我将URL值发送到另一个php文件以更新数据库。但每次我试图保存在数据库中,它被保存为0000-00-00。

代码如下:

echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>"  ; // results in the same jobrequestnumbers
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>"    ;//this too
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>"  ;// this one also 
echo "<td><a href='"update_request.php?jobrequestnumber={$row['jobrequestnumber']}&requestingcompany={$row['requestingcompany']}&dateforService={$row['dateforService']}'">Update</a></td>";

所以我试着在下面的更新代码之前回显值:然后就会得到正确的日期格式。

if (empty($errors)){
$jobrequestnumber = $_GET['jobrequestnumber'];
$requestingcompany = $_GET['requestingcompany'];
$dateforService = date("Y-m-d", strtotime($_GET['dateforService']));
    $query =    "UPDATE jobrequest SET 
                        requestingcompany = '{$requestingcompany}',
                        dateforService = $dateforService 
                    WHERE jobrequestnumber ={$jobrequestnumber}";

我很感谢你的建议,非常感谢。

Replace

dateforService = $dateforService 

dateforService = '$dateforService'

和以防万一

代替

jobrequestnumber ='$jobrequestnumber' // remove { & }. You are not using an array here. And add quotes around it