作者eye2468 (沉睡的猫)
看板PHP
标题Re: [请益] 资料写不进资料库..可以给我建议吗?谢谢!
时间Thu Oct 30 08:50:03 2008
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