0
不工作我有一個問題。mysqli的查詢工作在phpMyAdmin,在PHP腳本
我嘗試做簡單的查詢:
$this->db->query(" INSERT INTO prognosis(stamp,day_ep,day_ep_sum,day_time,day_time_sum,week_ep,week_ep_sum,week_time,week_time_sum,month_ep,month_ep_sum,month_time,month_ep_sum,year_ep,year_ep_sum,year_time,year_time_sum)
VALUES('$stamp',$today_ep,$today_ep_sum,$today_time,$today_time_sum,$week_ep,$week_ep_sum,$week_time,$week_time_sum,$month_ep,$month_ep_sum,$month_time,$month_time_sum,$year_ep,$year_ep_sum,$year_time,$year_time_sum)
");
...並表仍然是空的,所以我打印帶有值的HTML文件(元字符集= UTF-8)完整的查詢使用echo:
INSERT INTO prognosis (stamp, day_ep, day_ep_sum, day_time, day_time_sum, week_ep, week_ep_sum, week_time, week_time_sum, month_ep, month_ep_sum, month_time, month_time_sum, year_ep, year_ep_sum, year_time, year_time_sum) VALUES ('2016-01-09', 7, 5544, 318, 210948, 53, 5547, 2240, 211040, 289, 5744, 12844, 219835, 3366, 8822, 151232, 358223)
CTRL + C,CTRL + V到phpMyAdmin和表接受查詢
DESCRIBE(爲什麼?):
Array
(
[0] => Array
(
[Field] => id
[Type] => int(11)
[Null] => NO
[Key] => PRI
[Default] =>
[Extra] => auto_increment
)
[1] => Array
(
[Field] => stamp
[Type] => date
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[2] => Array
(
[Field] => day_ep
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[3] => Array
(
[Field] => day_ep_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[4] => Array
(
[Field] => day_time
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[5] => Array
(
[Field] => day_time_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[6] => Array
(
[Field] => week_ep
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[7] => Array
(
[Field] => week_ep_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[8] => Array
(
[Field] => week_time
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[9] => Array
(
[Field] => week_time_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[10] => Array
(
[Field] => month_ep
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[11] => Array
(
[Field] => month_ep_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[12] => Array
(
[Field] => month_time
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[13] => Array
(
[Field] => month_time_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[14] => Array
(
[Field] => year_ep
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[15] => Array
(
[Field] => year_ep_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[16] => Array
(
[Field] => year_time
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
[17] => Array
(
[Field] => year_time_sum
[Type] => int(11)
[Null] => YES
[Key] =>
[Default] =>
[Extra] =>
)
)
我注意到有趣的事情: 當我試圖找到這種行爲的原因,我試圖執行短查詢:
$this->db->query(" INSERT INTO prognosis(stamp,year_ep,year_ep_sum,year_time,year_time_sum)
VALUES('$stamp',$year_ep,$year_ep_sum,$year_time,$year_time_sum)
和它工作正常,但我必須執行完整版的查詢。
你有month_ep_sum兩次 - 代替$ month_time_sum – crafter
由於第二個,或許這是問題,但最後我重組了表。現在列名稱看起來像:標識,戳記,'鍵','值',並且每個參數都在其他行中。 –
很高興一切都很好。刪除帖子,如果它不適用了。 – crafter