sql中缺少参数

时间:2013-10-12 19:40:07

标签: php jquery mysql sql odbc

这是我的sql操作代码..

$conn= get_db_connection();
    var_dump($data);
    $PickupDate     =   date('m/d/Y', strtotime($data[17]));
    $OrderNum       =    $data[4];
    $TrackingID     =   $data[15];
echo $sql_1 =   'UPDATE Tracking SET Tracking.PickupDate = "'.$PickupDate.'", Tracking.Carrier = "USPS", Tracking.EmailSent = "-1", Tracking.Notes = "Inserted by TIA", Tracking.TrackingID = "'.$TrackingID.'", Tracking.External= "1" WHERE Tracking.OrderNum= "'.$OrderNum.'"';
$rs1=odbc_exec($conn,$sql_1);

中回显查询结果
  

更新跟踪SET Tracking.PickupDate =“10/03/2013”​​,   Tracking.Carrier =“USPS”,Tracking.EmailSent =“ - 1”,Tracking.Notes =   “由TIA插入”,Tracking.TrackingID =“9400110200881918988535”,   Tracking.External =“1”WHERE Tracking.OrderNum =“59836”

如果我将此查询直接粘贴到访问(此回显版本),它可以工作.. 但是当我通过我的odbc连接运行它时......错误是......

警告:odbc_exec():SQL错误:[Microsoft] [ODBC Microsoft Access驱动程序]参数太少。预期7.,第34行的D:\ wamp1 \ www \ ftp \ ftp_functions.php中的SQLExecDirect中的SQL状态07001

第94行是$rs1=odbc_exec($conn,$sql_1);

所以,我可以看到,每个参数都存在我的查询,仍然得到错误,

尝试对其进行数小时的排查,但没有成功,

有人能帮帮我吗? 提前谢谢

PS: pickdate,ordernum,trackingID,所有这些都是TEXT(使用石头边缘:(无法控制数据类型,但我相信它们应该是日期和int类型)

1 个答案:

答案 0 :(得分:0)

这对我有用

$sql_1  =   "UPDATE Tracking
 SET PickupDate='$PickupDate', TrackingID = $TrackingID, 
  Tracking.Carrier = 'USPS', Tracking.EmailSent = '-1', Tracking.Notes = 'Inserted by TIA', Tracking.External= '1'
 where OrderNum='$OrderNum'";

似乎odbc和ms-access正在用qoutes创建问题