0

I have the following code:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        $insertSQL = sprintf("INSERT INTO inventory_software_request (Software, Name, NISD, Room) VALUES (%s, %s, %s, %s)",
        GetSQLValueString $_POST['software[]'], "text"),
        GetSQLValueString($_POST['name'], "text"),
        GetSQLValueString($_POST['nisd'], "text"),
        GetSQLValueString($_POST['room'], "text"));

to send data to a MySQL database. the form includes a list of software with checkboxes. The user will be selecting 20 or more of the checkboxes. Their values are saved as an array with a number representing each checkbox.

When I submit the form and look at my database, the name, nisd and room all show but for the software is says "null." How do I get the software array to show up in the database?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by hielo
0

change: GetSQLValueString $_POST['software[]'], "text") to: GetSQLValueString( implode(',', $_POST['software']), "text")

0

I tried that and my whole form disappears, guess it didn't like that code.

0

since you are inserting text, change:

...VALUES (%s, %s, %s, %s)

to:

...VALUES ('%s', '%s', '%s', '%s')
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.