+ -
当前位置:首页 → 问答吧 → php mysql null 变咗0

php mysql null 变咗0

时间:2014-07-01

来源:互联网

睇完网上forum都试唔到。请师兄指点。

php code 如下

if($D2==0){
$D2=NULL;
}

入到去MYSQL 试咗FLOAT 同int都 变咗做 0。

请问我漏咗d乜? 已set(null=yes, default=null)

作者: oprso   发布时间: 2014-07-01

Can I see your SQL statement?

作者: McLoneIII   发布时间: 2014-07-01

引用:原帖由 McLoneIII 於 2014-6-18 13:03 发表
Can I see your SQL statement?
复制内容到剪贴板代码:$RecIns = "INSERT INTO HF.RecipeLab(RecID, HFCC, Date, D1, D1Q, D2, D2Q, D3, D3Q, D4, D4Q, A1, A1Q, A2, A2Q, Time, RC, DiscolorTest, RMK) VALUES ('$RecNo', '$HFCC', '$date','$D1','$D1Q','$D2','$D2Q','$D3','$D3Q','$D4','$D4Q','$A1','$A1Q','$A2','$A2Q','$timee','$RC','$DC','$RMK')";
mysql_query($RecIns) or die('Connection error -> ' . mysql_error());;
[ 本帖最后由 oprso 於 2014-6-18 01:11 PM 编辑 ]

作者: oprso   发布时间: 2014-07-01

引用:原帖由 oprso 於 2014-6-18 01:08 PM 发表

$RecIns = "INSERT INTO HF.RecipeLab(RecID, HFCC, Date, D1, D1Q, D2, D2Q, D3, D3Q, D4, D4Q, A1, A1Q, A2, A2Q, Time, RC, DiscolorTest, RMK) VALUES ('$RecNo', '$HFCC', '$date','$D1','$D1Q','$D2','$D2Q' ...
http://www.php.net/manual/en/language.types.string.php#language.types.string.casting
引用:NULL is always converted to an empty string.
另外,现在用 MySQL 应该用新的 API 了。
可参考:
http://www.php.net/manual/en/mysqli-stmt.execute.php

作者: xianrenb   发布时间: 2014-07-01