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?

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

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

since you are inserting text, change:

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

to:

...VALUES ('%s', '%s', '%s', '%s')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.