Re: [請益] 資料寫不進資料庫..可以給我建議嗎?謝謝!
43
: 這邊 function mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id,
: $room_id, $owner, $name, $type, $description,
: $project)
: {
: global $tbl_entry;
: $name = slashes($name);
: $description = slashes($description);
: //$project = slashes($project);
: // make sure that any entry is of a positive duration
: // this is to trap potential negative duration created when DST comes
: // into effect
: if ($endtime > $starttime)
: {
: $sql = "INSERT INTO $tbl_entry (start_time, end_time, entry_type,
: repeat_id, room_id, create_by, name, type, description, project)
: VALUES ($starttime, $endtime, $entry_type,$repeat_id, $room_id,
: '$owner', '$name', '$type', $description','$project')";
^^^^^^^
變數內無值
所以寫入資料庫中當然是空白的
: if (sql_command($sql) < 0)
: {
: return 0;
: }
: return sql_insert_id("$tbl_entry", "id");
: }
: else
: {
: return 0;
: }
: }
: 我覺奇怪是 project欄位 我有預設值QQQ 但是user填完後 寫到資料庫卻是空白!
sql中的預設值,應該是什麼都沒有寫入時,才會幫你加的
什麼都沒有的意思是指,並沒有寫入這個欄位,上頭的sql是有用到的
: 這可能是那邊問題呢?
: 對不起 可能比較長 排版比較不清楚! 大家有啥建議可以提供我嗎?
: 謝謝!!
建議是直接判斷,如果無值就將$project="QQQ";
不然就要用兩個SQL,一個有project,一個沒有project
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.64.38.166
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章