我正在创建一个自定义模块,它还允许编辑页面编辑特殊节点。 在游乐场下面有一个更新按钮;所以我为这一切做了一个表格 以下是表单
的hook_submit function game_week_edit_form_submit($form_id, &$form_state)
{
$result = db_query("UPDATE {game_week} SET
start_time = %s, open_time = %s , close_time = %s WHERE game_week_id= %d",
$form_state['values']['start_time'], $form_state['values']['open_time'],
$form_state['values']['close_time'],$form_state['values']['game_week_id']);
}
答案 0 :(得分:3)
您需要使用引号将字符串包装在查询中:
function game_week_edit_form_submit($form_id, &$form_state)
{
$result = db_query("UPDATE {game_week} SET
start_time = '%s', open_time = '%s' , close_time = '%s' WHERE game_week_id = %d",
$form_state['values']['start_time'], $form_state['values']['open_time'],
$form_state['values']['close_time'],$form_state['values']['game_week_id']);
}
如果不是这样,请查看最近日志条目以查找任何数据库失败 - admin / reports / dblog