【问题标题】:How do I insert value of field with a shared name into MySQL?如何将具有共享名称的字段值插入 MySQL?
【发布时间】:2013-10-28 14:49:08
【问题描述】:

我有一些具有共享名称的字段。

我想插入具有数据(或值)的任何一个。 jquery show and hide 一次只显示一个具有共享名称的字段。

我尝试在每个字段中设置相同的名称,如下所示:

mailer_type

我试着把它做成这样的数组:

mailer_type[]

我试着把它做成这样的数组:

mailer_type[mt]

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type[]']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type[mt]']));

为了获取帖子数据,我尝试了这个:

$mailer_type = mysql_real_escape_string(htmlspecialchars($_POST['mailer_type']['mt']));

将数据插入数据库始终相同。没有尝试过不同的东西:

mysql_query("INSERT jobs SET mailer_type='$mailer_type' ") or die(mysql_error());

每次我提交表单时,要么没有任何内容进入表格列,要么 0 进入表格列。没有插入该字段的实际值。

【问题讨论】:

    标签: php jquery mysql sql


    【解决方案1】:

    试试这个:

    $mailer_type = mysql_real_escape_string(htmlspecialchars($_REQUEST['mailer_type']));

    而不是post,看是否得到post数据。

    【讨论】:

    • 尝试了以不同方式命名表单字段的方法,但两次都不起作用。 mailer_type, mailer_type[], mailer_type[mt]
    猜你喜欢
    • 1970-01-01
    • 2014-12-07
    • 1970-01-01
    • 2017-01-15
    • 2016-07-05
    • 2012-07-22
    • 2020-10-20
    • 1970-01-01
    • 2010-10-03
    相关资源
    最近更新 更多