我正在尝试这些复选框(最终将两个连接在一起并插入)到数据库中。我已经尝试了几种方法并搜索了很多页面,但是当我尝试插入时,我的页面一直在破碎。我实际上并没有在我的apache日志中收到错误,但是触发了一条消息让我相信它有某种sql错误(最后的else语句,这是检查查询是否受影响任何行)。在我将foreach和其他奖励添加到查询中之前,不会抛出错误。
以下是表单部分
<label><input type="checkbox" name="check_list[]" Value = "Castle Connolly Top U.S. Doctor" />Castle Connolly Top U.S. Doctor</label>
<!-- <input type="text" name="check_year" value="<php echo decode_text($check_year);?>"/> -->
<label><input type="checkbox" name="check_list[]" Value = "Vitals Patients Choice"/>Vitals Patient's Choice</label>
<!--<input type="text" name="check_year" value="<php echo decode_text($check_year);?>"/> -->
<label><input type="checkbox" name="check_list[]" Value = "Vitals Compassionate Doctor"/>Vital's Compassionate Doctor Recognition</label>
<!--<input type="text" name="check_year" value="<php echo decode_text($check_year);?>"/> -->
<label><input type="checkbox" name="check_list[]" Value = "Super Doctor"/>Super Doctor</label>
<!--<input type="text" name="check_year" value <php echo decode_text($check_year);?>"/> -->
插入
$additional_awards = '';
$check_list = $_POST['check_list'];
foreach($check_list as $check)
{
$additional_awards .= $check.", ";
}
// insert new user
$sql = 'INSERT INTO docflight_doctors (
email,
user_name,
user_password,
additional_awards,
preferred_language,
date_created,
registered_from_ip,
last_logged_ip,
is_active,
is_removed,
comments,
registration_code )
VALUES(
\''.encode_text($email).'\',
\''.encode_text($user_name).'\',
\''.$user_password.'\',
\''.$additional_awards.'\',
\''.Application::Get('lang').'\',
\''.date('Y-m-d H:i:s').'\',
\''.$user_ip.'\',
\'\',
'.$is_active.',
0,
\'\',
\''.$registration_code.'\')';
if(database_void_query($sql) > 0){
/// do other stuff
else{
///echo mysql_error();
$msg = draw_important_message(_CREATING_ACCOUNT_ERROR, false);
FIXED,\&#39;&#39;。$ user_password。&#39; \&#39;,应该是&#39;。$ user_password。&#39;,由于某种原因...... 。