Hey Thomas, sorry to bother you again,

I ran a debug that would echo the query when I submit the form. Here is what it displays:

INSERT INTO host (host_id, time, ip, company_name,company_url,contact_first,contact_last,contact_email,address_1,address_2,city,zip,state,country,established,phone,fax,info,platform,type,cp,support,payment) VALUES ('', '1093196872', 'xxx.xxx.xxx.xxx', 'test','','','','','','','','','','-- Datacenter Location --','-- Select A Year --','','','','2_3','Array','','','')

so it just stores the checkboxes of the Type of Hosting as 'Array.'

I think the problem is with this:

	$arrValuesType = array();
	for ($i=0;$i<count($fields);$i++) {

  $valType = "";
  if ($fields[$i] == "type") {
    // use platform data
    $valType = $type;
  } else {
    // use current post data
    $valType = isset($_POST[$fields[$i]]) ? $_POST[$fields[$i]] : "";
  }

  // escape the stuff so submitted values don't break up the query
  $valType = "'".mysql_escape_string($valType)."'";
  $arrValuesType[] = $valType;
}


// create value list and field list
$values = implode(",",$arrValues);
$fieldlist = implode(",",$fields);

Especially with the last couple of lines. Shouldn'i I have $arrValuesType somewhere in there? I mean I should implode the selected thing, shouldn't I?

thanks

    Please post the complete script attached to your post. You can do this with just one loop with a slight modification.

    The second loop get's ignored since the code is based on using just one loop.

    Thomas

      Kindly find attached the requested script as .txt file.

      Thanks

        Hi,

        find attached the modified script.

        These three arrays make up the check box groups:

          // if the possible platforms are stored in a table)
          $arrCheckboxValues = array("platform"     => array(1 => 'Windows',2 => 'Linux',3 => 'FreeBSD',4 => 'Apple'),
                                     "type"         => array(1 => 'Free',2 => 'Shared',3 => 'eCommerce',4 => 'Reseller',5 => 'Semi-Dedicated',6 => 'Dedicated',7 => 'Co-Location'),
                                     "cp"           => array(1 => 'CPanel/WHM',2 => 'Plesk',3 => 'Ensim',4 => 'Helm'),
                                     "support"      => array(1 => 'Phone',2 => 'Live',3 => 'IM',4 => 'Forum',5 => 'Help Desk',6 => 'Email'),
                                     "payment"      => array(1 => 'Visa',2 => 'Mastercard',3 => 'AmEx',4 => 'Discover',5 => 'PayPal',6 => 'Check/MO',7 => 'Other')
                                    );
        
          $arrCheckboxGroups = array("platform"     => "Platforms supported",
                                     "type"         => "Type of Hosting Offered",
                                     "cp"           => "Control Panel Supported",
                                     "support"      => "Customer Support Service Offered",
                                     "payment"      => "Type of Payment Accepted"
                                    );
        
          $fields = array('company_name','company_url','contact_first','contact_last',
                          'contact_email','address_1','address_2','city','zip','state',
                          'country','established','phone','fax','info','platform','type','cp',
                          'support','payment');
        

        You only need to modify the arrays to add further values (e.g. to add more control panels or something like that).

        Thomas

          An error:

          Replace
          while ($cnt%0) {
          by
          while ($cnt%4 > 0) {

          in the PHP block at the end of the script. This ensures that the number of cells in a row is 4 even if there are less than four items.

          Thomas

            Hey,

            I don't have anything by

            while ($cnt%0)

            could you clarify this please?

            Thanks.

              It's on line 268 in the script I attached to the post I posted at 9:22 pm.

                Hey there,

                Thank you soo much... I haven't even see it 🙂

                I get an error though on line 37 which is:

                @mysql_select_db($database;$conn) or die("Unable to select database: ".mysql_error());

                What is this $conn doing there?

                Thanks again 😉

                  This was a modification I made to test stuff but I messed up the code a little bit. Replace the ; by ,

                  I always use the connection resource along with mysql_query but you can do it without as long as you only have one connection in a script.

                    Awesome, thank you soo much for all your help 😃

                    Works like a charm 🙂

                    Thank you

                      Glad to hear that 🙂

                      btw ... don't forget to mark the thread resolved if there are no questions remaining 🙂

                      Thomas

                        Write a Reply...