Question

Insert MYSQL records into database from array

Asked by: danjen

Hello Experts!

I have a MYSQL statement that creates several groups of radio buttons that display options for a product.

I need to know how to get the value of the selected options and insert them into a MYSQL database.

The value column is what I need to insert in to MYSQL.

Thanks for the help.

mysql_select_db($database_localhost, $localhost);
$query_SortCapacity = sprintf("SELECT GROUP_CONCAT(DISTINCT concat('<input type=\"radio\"',' name=\"', SortFields.Field,'\" id=\"',SortFields.Field,'\" ''value=\"',SortFieldVals.Value,'\"' ,'/>',SortFieldVals.Value)Order by SortFieldVals.ValueDisplayOrder Separator ' ') AS Value,SortFields.Field,Categories.Category_ID, Categories.pkID FROM SortFields INNER JOIN Categories on Categories.pkID = SortFields.pkCategory INNER JOIN SortFieldVals on SortFieldVals.pkSortField = SortFields.pkID WHERE Categories.pkID = %s and  SortFields.Field <> 'QUALITY'  and SortFields.Field <> 'QUALITY LEVEL'  GROUP BY SortFieldVals.Field ", GetSQLValueString($MMColParam_SortCapacity, "int"));
$SortCapacity = mysql_query($query_SortCapacity, $localhost) or die(mysql_error());
$row_SortCapacity = mysql_fetch_assoc($SortCapacity);
$totalRows_SortCapacity = mysql_num_rows($SortCapacity);

                                  
1:
2:
3:
4:
5:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-05 at 14:05:14ID24876278
Tags

php

,

mysql

Topics

PHP Scripting Language

,

PHP and Databases

,

MySQL Server

Participating Experts
1
Points
500
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. MySQL INSERT table contents
    I need to read the contents of a table called 'Makes', sort it and INSERT it into table Makes_temp. Is there a way to do this with MysQL statements ? Thanks, $result = mysql_query("SELECT manufacturers_make FROM makes ORDER BY manufacturers_make ASC", $mysql_access...
  2. PHP and mysql_insert_id()
    Hey all, Why would mysql_insert_id constantly return '0' for the following code, even though I have rows with an auto_increment column in the table I'm working with that has more than 0 rows? $link = mysql_connect($cfg['build_meta_hostname'], $cfg['build_meta_username'...
  3. mysql_insert_id
    Hi to all experts, I have a question.I use php &mysql and i get identity number with mysql_insert_id. I use mysql_insert_id function after insert clause.But i wonder that i imagine there can execute alot of insert statement.And i use connection pooling. does mysql give me...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: seetharamlPosted on 2009-11-05 at 21:21:30ID: 25756764

Hi danjen,

Can you please check  the below code and let me know if you need anything,


Thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
	if($_REQUEST["submit"]) {
		$ins_query = "INSERT INTO Products (product_seleced) VALUES ('" . $_REQUEST['rad'] . "')";
		mysql_query($ins_query);
	}
?>
<body>
<form>
	<input type="radio" name="rad" id="rad" value="ddd" />
	<input type="submit" id="submit" name="submit" />
</form> 
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:

Select allOpen in new window

 

by: danjenPosted on 2009-11-05 at 21:28:14ID: 25756784

This looks like it is only select one of the radio options. The mysql statement is creating multiple radio groups and I need to insert all of the checked items into the database. Here is an example of what it might create depending on the product.

Capacity:
12cf
14cf
16cf

Width
24in
46in
52in

Height
12in
14in
16in

Cycles
2-4
5-9
10-12

Each of the options is a group of radio buttons

 

by: seetharamlPosted on 2009-11-05 at 21:39:58ID: 25756831

Hi,

Please try below code and let me know,


Thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
        if($_REQUEST["submit"]) {
			foreach($_REQUEST as $key=>$value) {
				$Prefix = "rad_"
				$pos = strpos($key, $Prefix);
				if (!is_integer($pos)) {
				}else{		
					$tmp_name = split("_",$key);
					$ins_query = "INSERT INTO Products (product,product_seleced) VALUES ('" . $tmp_name[1] . "','" . $value . "')";
					mysql_query($ins_query);
				}
			}		
        }
?>
<body>
<form>
	Capacity:<br />
        <input type="radio" name="rad_Capacity" value="12cf" />12cf
        <input type="radio" name="rad_Capacity" value="14cf" />14cf
        <input type="radio" name="rad_Capacity" value="16cf" />16cf
	<br />Width<br />
        <input type="radio" name="rad_Width" value="24in" />24in
        <input type="radio" name="rad_Width" value="46in" />46in
        <input type="radio" name="rad_Width" value="52in" />52in
	<br />Height<br />
        <input type="radio" name="rad_Height" value="12in" />12in
        <input type="radio" name="rad_Height" value="14in" />14in
        <input type="radio" name="rad_Height" value="16in" />16in
	<br />	
        <input type="submit" id="submit" name="submit" />
</form> 
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:

Select allOpen in new window

 

by: danjenPosted on 2009-11-05 at 21:55:01ID: 25756879

I get this error:
Parse error: syntax error, unexpected T_VARIABLE in Admin/Products_Insert.php on line 916

at this line:
$pos = strpos($key, $Prefix);

 

by: seetharamlPosted on 2009-11-05 at 21:59:00ID: 25756895

Hi,

Please put semicolon i.e ";" in the line and let me know

$Prefix = "rad_";


Thanks

 

by: danjenPosted on 2009-11-05 at 22:08:52ID: 25756934

thanks - that fixed the error.

Now I am not getting any errors, but the values are not posting to the database.

Here is the form elements code:
             <table width="410px">
  <tr>
      </tr>
      <tr>
              <td align="left" valign="top"><h3>CAPACITY</h3>

                 <input type="radio" name="rad_CAPACITY" id="CAPACITY" 'value="1 TO 2 PERSON"/>1 TO 2 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" 'value="3 TO 4 PERSON"/>3 TO 4 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" 'value="5 OR MORE PERSON"/>5 OR MORE PERSON<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>ENERGY RATING</h3>
                 <input type="radio" name="rad_ENERGY RATING" id="ENERGY RATING" 'value="ENERGY STAR&reg;"/>ENERGY STAR&reg;<br />
<br />

            </tr>
        <tr>
              <td align="left" valign="top"><h3>POWER SOURCE</h3>
                 <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" 'value="ELECTRIC"/>ELECTRIC <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" 'value="GAS"/>GAS<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>WIDTH</h3>

                 <input type="radio" name="rad_WIDTH" id="WIDTH" 'value="24"/>24 <input type="radio" name="rad_WIDTH" id="WIDTH" 'value="27"/>27 <input type="radio" name="rad_WIDTH" id="WIDTH" 'value="29"/>29<br />
<br />
            </tr>
    </table>
Here is the insert code

if (isset($_POST["insert"]))
 {
                        foreach($_REQUEST as $key=>$value) {
                                $Prefix = "rad_";
                                $pos = strpos($key, $Prefix);
                                if (!is_integer($pos)) {
                                }else{          
                                        $tmp_name = split("_",$key);
                                        $ins_query = "INSERT INTO UA_Sorts (SKU,Type,Value) VALUES (".((isset($_POST["ProductSKU"]))?$_POST["ProductSKU"]:"")  .",'" . $tmp_name[1] . "','" . $value . "')";
                                        mysql_query($ins_query);
                                }
                        }              
        }


Thank you for the help.

 

by: seetharamlPosted on 2009-11-05 at 22:23:41ID: 25756977

Hi danjen,

In your code i found three issue one is there is no submit button name like "insert" and another one is why each is like 'value= instead of value= also there is no <form>  please check modified code below and let me know,

Thanks,

<form>
           <table width="410px">
  <tr>
      </tr>
      <tr>
              <td align="left" valign="top"><h3>CAPACITY</h3> 
                 <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="1 TO 2 PERSON"/>1 TO 2 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="3 TO 4 PERSON"/>3 TO 4 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="5 OR MORE PERSON"/>5 OR MORE PERSON<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>ENERGY RATING</h3>
                 <input type="radio" name="rad_ENERGY RATING" id="ENERGY RATING" value="ENERGY STAR&reg;"/>ENERGY STAR&reg;<br />
<br /> 
            </tr>
        <tr>
              <td align="left" valign="top"><h3>POWER SOURCE</h3>
                 <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" value="ELECTRIC"/>ELECTRIC <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" value="GAS"/>GAS<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>WIDTH</h3> 
                 <input type="radio" name="rad_WIDTH" id="WIDTH" value="24"/>24 <input type="radio" name="rad_WIDTH" id="WIDTH" value="27"/>27 <input type="radio" name="rad_WIDTH" id="WIDTH" value="29"/>29<br />
<br />
            </tr>
			
        <tr>
              <td align="left" valign="top">
			  	<input type="submit" name="insert" id="insert" >
			  </td>
            </tr>			
			
    </table>
</form>
<?
if (isset($_REQUEST["insert"]))
 {
 print "GGG";
	foreach($_REQUEST as $key=>$value) {
			$Prefix = "rad_";
			$pos = strpos($key, $Prefix);
			if (!is_integer($pos)) {
			}else{          
				$tmp_name = split("_",$key);
				$ins_query = "INSERT INTO UA_Sorts (SKU,Type,Value) VALUES (".((isset($_POST["ProductSKU"]))?$_POST["ProductSKU"]:"")  .",'" . $tmp_name[1] . "','" . $value . "')";
				mysql_query($ins_query);
			}
	}              
}
?>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:

Select allOpen in new window

 

by: danjenPosted on 2009-11-05 at 22:35:15ID: 25757030

Thanks for the quick reply. I fixed the single quote in front of value.

Insert is the name I gave the button to post the form. There are no form tags in the code I pasted because the form is really long. There are other fields in the form that insert fine. Just the array is not posting to the database.

It is still not posting to the database.

Here is the new error I get

GGG
Warning: Cannot modify header information - headers already sent by (output started at /Admin/Products_Insert.php:915) in Admin/Products_Insert.php on line 955

Warning: Cannot modify header information - headers already sent by (output started at /Admin/Products_Insert.php:915) in WA_ValidationToolkit/WAVT_Scripts_PHP.php on line 71

Line 915 is the print GGGG

 

by: seetharamlPosted on 2009-11-05 at 22:50:16ID: 25757125

Hi danjen,

Please try exactly like below, becoz we need the form tag to post the value other wise can you give me your code i will check the issue please and let me know,


Thanks

<form>
           <table width="410px">
  <tr>
      </tr>
      <tr>
              <td align="left" valign="top"><h3>CAPACITY</h3> 
                 <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="1 TO 2 PERSON"/>1 TO 2 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="3 TO 4 PERSON"/>3 TO 4 PERSON <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="5 OR MORE PERSON"/>5 OR MORE PERSON<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>ENERGY RATING</h3>
                 <input type="radio" name="rad_ENERGY RATING" id="ENERGY RATING" value="ENERGY STAR&reg;"/>ENERGY STAR&reg;<br />
<br /> 
            </tr>
        <tr>
              <td align="left" valign="top"><h3>POWER SOURCE</h3>
                 <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" value="ELECTRIC"/>ELECTRIC <input type="radio" name="rad_POWER SOURCE" id="POWER SOURCE" value="GAS"/>GAS<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>WIDTH</h3> 
                 <input type="radio" name="rad_WIDTH" id="WIDTH" value="24"/>24 <input type="radio" name="rad_WIDTH" id="WIDTH" value="27"/>27 <input type="radio" name="rad_WIDTH" id="WIDTH" value="29"/>29<br />
<br />
            </tr>
                        
        <tr>
              <td align="left" valign="top">
                                <input type="submit" name="insert" id="insert" >
                          </td>
            </tr>                       
                        
    </table>
</form>
<?
if (isset($_REQUEST["insert"]))
 {
         foreach($_REQUEST as $key=>$value) {
                        $Prefix = "rad_";
                        $pos = strpos($key, $Prefix);
                        if (!is_integer($pos)) {
                        }else{          
                                $tmp_name = split("_",$key);
                                $ins_query = "INSERT INTO UA_Sorts (SKU,Type,Value) VALUES (".((isset($_POST["ProductSKU"]))?$_POST["ProductSKU"]:"")  .",'" . $tmp_name[1] . "','" . $value . "')";
                                mysql_query($ins_query);
                        }
        }              
}
?>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: danjenPosted on 2009-11-05 at 22:59:42ID: 25757165

Here is the entire form. I have posted the inset exactly how you posted above, but nothing is inserted into the database. I can do an individual insert into the database by sort field type and it works fine, but the multiple insert you have posted does not seem to be working.

Thanks again for the help.

                <form action="Products_Insert.php" method="post" enctype="multipart/form-data" name="WADAInsertForm" id="WADAInsertForm">
            <div class="contentBox productBox">
              <div class="productForm">
                <h2>Class: REFRIGERATORS<input name="Class" type="hidden" value="11" /></h2>
                <h2>Category: Cabinet Depth: Bottom Freezer<input name="Category" type="hidden" value="62" /></h2>
                <fieldset class="insertForm insertForm-products">
                  <p>
                    <label for="ProductLive" class="readonly-checkbox">Available Online:</label> 
                    <input checked="checked" name="ProductLive" type="checkbox" id="ProductLive" value="1" />
                    (check to make this item available for sale) </p>
                    <p><label>Brand</label><select name="Brand">
                      <option value="" >Please select</option>
                                            <option value="9">Amana</option>
                                            <option value="18">Asko</option> 
                                            <option value="25"selected="selected">Bosch</option>
                                            <option value="42">Dacor</option>
                                            <option value="44">Danby</option>
                                            <option value="45">DCS</option>
                                            <option value="56">Electrolux</option>
                                            <option value="98">Electrolux Icon</option> 
                                            <option value="61">Estate</option>
                                            <option value="67">Fisher & Paykel</option>
                                            <option value="70">Frigidaire</option>
                                            <option value="71">Frigidaire AC</option>
                                            <option value="267">GE</option>
                                            <option value="143">GE Monogram</option> 
                                            <option value="95">Hotpoint</option>
                                            <option value="103">JENN-AIR</option>
                                            <option value="110">KitchenAid</option>
                                            <option value="360">LG</option>
                                            <option value="123">LG</option>
                                            <option value="135">Maytag</option> 
                                            <option value="139">Miele</option>
                                            <option value="199">Sharp Appliances</option>
                                            <option value="213">Subzero</option>
                                            <option value="224">Thermador</option>
                                            <option value="237">Viking</option>
                                            <option value="251">W. C. Wood's</option> 
                                            <option value="245">Whirlpool</option>
                                            <option value="250">Wolf</option>
                                          </select></p>
                  <p>
                    <label for="ProductSKU">SKU:</label>
                    <span id="sprytextfield1">
                      <input name="ProductSKU" type="text" id="ProductSKU" value="test1001" size="32" onblur="if (document.getElementById('ProductSKUServerValidation')) document.getElementById('ProductSKUServerValidation').style.display='none';" /> 
                      <span class="textfieldRequiredMsg">Please enter a SKU or product ID.</span></span>
                                      </p>
                  <p>
                    <label>Color:</label>
                    <select name="Color" id="Color" onchange="updateColor();">
                      <option value="" >Choose one</option>
                      <option value="Bisque" >Bisque</option> 
                      <option value="Black" >Black</option>
                      <option value="Stainless" selected="selected">Stainless</option>
                      <option value="Other" >Other</option>
                    </select>
                  </p>
                  <p> <span id="sprytextfield7">
                    <label>Color Description</label> 
                    <input name="ColorDescription" type="text" id="ColorDescription" value="Stainless" />
                    <span class="textfieldRequiredMsg">A value is required.</span></span> </p>
                  <p>
                    <label for="ProductPrice">Regular Price: $</label>
                    <span id="sprytextfield4">
                      <input name="ProductPrice" type="text" id="ProductPrice" value="999" size="32" onblur="if (document.getElementById('ProductPriceServerValidation')) document.getElementById('ProductPriceServerValidation').style.display='none';" />
                      <span class="textfieldRequiredMsg">Please enter the price of this product in your store.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> 
                                      </p>
                  <p> <span id="sprytextfield6">
                    <label>Sale Price: $</label>
                    <input name="sale_price" type="text" id="sale_price" value="199" />
                  </span> </p>
                  <p>
                    <label for="ProductWeight">Weight in lbs:</label> 
                    <span id="sprytextfield5">
                      <input name="ProductWeight" type="text" id="ProductWeight" value="10" size="32" onblur="" />
                      <span class="textfieldRequiredMsg">Please enter a product weight.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
                                      </p>
                  <div>
                 <h2> If this model is available in other colors:</h2>
              <div id="Model"> 
                <label>Model Base:</label>
                <input name="Model_Base" type="text" />
              </div>
              </div>
                </fieldset>
              </div>
              <div class="productImages">
                <h1>Product Uploads:</h1> 
                <fieldset class="insertForm insertForm-productImages">
                  <p class="nobottom">
                    <label for="Image1" class="readonly-image">Image 1:</label>
                    <input name="Image1" type="file" id="Image1" onchange="WAValidateFE(document.getElementById('WADAInsertForm').ProductSKU,document.getElementById('WADAInsertForm').ProductSKU.value,'- Invalid file extension','.gif, .jpg, .jpeg, .png',document.getElementById('WADAInsertForm').ProductSKU,0,true);WAValidateHD(document,'ProductThumbValidation',false);if (document.getElementById('ProductThumbServerValidation')) document.getElementById('ProductThumbServerValidation').style.display='none'" />
                                          <span class="textfieldServerError" id="ProductThumbServerValidation"> Please enter a valid file (.gif, .jpg, .jpeg, .png).</span>
                                          <span class="textfieldClientError" id="ProductThumbValidation">Please enter a valid file (.gif, .jpg, .jpeg, .png).</span> </p> 
                  <p class="nobottom">
                    <label for="Image2" class="readonly-image">Image 2:</label>
                    <input name="Image2" type="file" id="Image2" onchange="WAValidateFE(document.getElementById('WADAInsertForm').ProductSKU,document.getElementById('WADAInsertForm').ProductSKU.value,'- Invalid file extension','.gif, .jpg, .jpeg, .png',document.getElementById('WADAInsertForm').ProductSKU,0,true);WAValidateHD(document,'ProductImageValidation',false);if (document.getElementById('ProductImageServerValidation')) document.getElementById('ProductImageServerValidation').style.display='none'" />
                                        <span class="textfieldClientError" id="ProductImageValidation">Please enter a valid file (.gif, .jpg, .jpeg, .png).</span> </p>
                    
                    <p><label>Use and Care Guide</label><input name="Guides" type="file" /></p>
                   <p> <label>Product Specs</label><input name="Specifications" type="file" /></p> 
                 <p>   <label>Energy Guide</label><input name="Energy" type="file" /></p>
                </fieldset>
              
              <p>
               <table width="410px">
  <tr>
      </tr>
      <tr>
              <td align="left" valign="top"><h3>CAPACITY</h3> 
                 <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="COMPACT 12 & UNDER"/>COMPACT 12 & UNDER <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="14 - 16 cu ft"/>14 - 16 cu ft <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="17 - 19 cu ft"/>17 - 19 cu ft <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="20 - 22 cu ft"/>20 - 22 cu ft <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="23 - 26 cu ft"/>23 - 26 cu ft <input type="radio" name="rad_CAPACITY" id="CAPACITY" value="27 and Higher"/>27 and Higher<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>ENERGY RATING</h3> 
                 <input type="radio" name="rad_ENERGY RATING" id="ENERGY RATING" value="ENERGY STAR&reg;"/>ENERGY STAR&reg;<br />
<br />
            </tr>
        <tr>
              <td align="left" valign="top"><h3>SHELVING</h3>
                 <input type="radio" name="rad_SHELVING" id="SHELVING" value="WIRE"/>WIRE <input type="radio" name="rad_SHELVING" id="SHELVING" value="GLASS"/>GLASS <input type="radio" name="rad_SHELVING" id="SHELVING" value="SPILLPROOF GLASS"/>SPILLPROOF GLASS<br />
<br /> 
            </tr>
        <tr>
              <td align="left" valign="top"><h3>WIDTH</h3>
                 <input type="radio" name="rad_WIDTH" id="WIDTH" value="18"/>18 <input type="radio" name="rad_WIDTH" id="WIDTH" value="19"/>19 <input type="radio" name="rad_WIDTH" id="WIDTH" value="21"/>21 <input type="radio" name="rad_WIDTH" id="WIDTH" value="23"/>23 <input type="radio" name="rad_WIDTH" id="WIDTH" value="24"/>24 <input type="radio" name="rad_WIDTH" id="WIDTH" value="26"/>26 <input type="radio" name="rad_WIDTH" id="WIDTH" value="28"/>28 <input type="radio" name="rad_WIDTH" id="WIDTH" value="30"/>30 <input type="radio" name="rad_WIDTH" id="WIDTH" value="31"/>31 <input type="radio" name="rad_WIDTH" id="WIDTH" value="32"/>32 <input type="radio" name="rad_WIDTH" id="WIDTH" value="33"/>33 <input type="radio" name="rad_WIDTH" id="WIDTH" value="34"/>34 <input type="radio" name="rad_WIDTH" id="WIDTH" value="35"/>35 <input type="radio" name="rad_WIDTH" id="WIDTH" value="36"/>36 <input type="radio" name="rad_WIDTH" id="WIDTH" value="39"/>39 <input type="radio" name="rad_WIDTH" id="WIDTH" value="42"/>42 <input type="radio" name="rad_WIDTH" id="WIDTH" value="45"/>45 <input type="radio" name="rad_WIDTH" id="WIDTH" value="48"/>48<br /> 
<br />
            </tr>
    </table>
              </p>
              </div>
            </div>
            <h1>Dimensions</h1>
            <h2>Type in any dimensions for this product</h2> 
            <div class="contentBox">
            <div><input type="hidden" id="Dimensions" name="Dimensions" value="" style="display:none" /><input type="hidden" id="Dimensions___Config" value="CustomConfigurationsPath=../custom/Products_Insert_Dimensions1.js" style="display:none" /><iframe id="Dimensions___Frame" src="../WA_iRite/editor/fckeditor.html?InstanceName=Dimensions&amp;Toolbar=Default" width="750px" height="200px" frameborder="0" scrolling="no"></iframe></div></div>
<h1>Short Description</h1>
            <h2>This content will display on the customer's Cart page after adding this product.</h2>
            <div class="contentBox">
                            <div><input type="hidden" id="ProductCartDesc" name="ProductCartDesc" value="&lt;p&gt;test&lt;/p&gt;" style="display:none" /><input type="hidden" id="ProductCartDesc___Config" value="CustomConfigurationsPath=../custom/Products_Insert_ProductCartDesc1.js" style="display:none" /><iframe id="ProductCartDesc___Frame" src="../WA_iRite/editor/fckeditor.html?InstanceName=ProductCartDesc&amp;Toolbar=Default" width="750px" height="200px" frameborder="0" scrolling="no"></iframe></div>            </div>
            <h1>Long Description</h1> 
            <h2>This content will display on the Product Detail page for this product.</h2>
            <div class="contentBox">
                            <div><input type="hidden" id="ProductShortDesc" name="ProductShortDesc" value="&lt;p&gt;test&lt;/p&gt;" style="display:none" /><input type="hidden" id="ProductShortDesc___Config" value="CustomConfigurationsPath=../custom/Products_Insert_ProductShortDesc1.js" style="display:none" /><iframe id="ProductShortDesc___Frame" src="../WA_iRite/editor/fckeditor.html?InstanceName=ProductShortDesc&amp;Toolbar=Default" width="750px" height="600px" frameborder="0" scrolling="no"></iframe></div>            </div>
            <h1>Features Description</h1>
            <h2>This content will display on the Product Detail page for this product.</h2>
            <div class="contentBox"> 
                            <div><input type="hidden" id="ProductLongDesc" name="ProductLongDesc" value="&lt;p&gt;testtqwerqwreq&lt;/p&gt;" style="display:none" /><input type="hidden" id="ProductLongDesc___Config" value="CustomConfigurationsPath=../custom/Products_Insert_ProductLongDesc1.js" style="display:none" /><iframe id="ProductLongDesc___Frame" src="../WA_iRite/editor/fckeditor.html?InstanceName=ProductLongDesc&amp;Toolbar=Default" width="750px" height="600px" frameborder="0" scrolling="no"></iframe></div>            </div>
            <div class="buttons-center">
              <input type="submit" name="insert" class="ie_btn" id="insert" value="Finish" alt="Insert" onclick="if (document.getElementById('ProductCategoryIDServerValidation')) document.getElementById('ProductCategoryIDServerValidation').style.display='none';if (document.getElementById('ProductSKUServerValidation')) document.getElementById('ProductSKUServerValidation').style.display='none';if (document.getElementById('ProductNameServerValidation')) document.getElementById('ProductNameServerValidation').style.display='none';if (document.getElementById('ProductStockServerValidation')) document.getElementById('ProductStockServerValidation').style.display='none';if (document.getElementById('ProductPriceServerValidation')) document.getElementById('ProductPriceServerValidation').style.display='none';if (document.getElementById('ProductWeightServerValidation')) document.getElementById('ProductWeightServerValidation').style.display='none';if (document.getElementById('ProductThumbServerValidation')) document.getElementById('ProductThumbServerValidation').style.display='none';if (document.getElementById('ProductImageServerValidation')) document.getElementById('ProductImageServerValidation').style.display='none';" />
              <input type="button" name="cancel" id="cancel" value="Cancel" onclick="window.location = 'Products_Results.php';" />
            </div>
          </form>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:

Select allOpen in new window

 

by: seetharamlPosted on 2009-11-05 at 23:18:44ID: 25757242

Hi danjen:-

You are post the value to Products_Insert.php, so you need to create Products_Insert.php and put the below code to that file and need to change databse username and pwd also databasename, please try below and let me know,

Thanks

<?
if (isset($_REQUEST["insert"]))
 {
 
mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error());
mysql_select_db("mydb");  

         foreach($_REQUEST as $key=>$value) {
				$Prefix = "rad_";
				$pos = strpos($key, $Prefix);
				if (!is_integer($pos)) {
				}else{          
						$tmp_name = split("_",$key);
						$ins_query = "INSERT INTO UA_Sorts (SKU,Type,Value) VALUES (".((isset($_POST["ProductSKU"]))?$_POST["ProductSKU"]:"")  .",'" . $tmp_name[1] . "','" . $value . "')";
						mysql_query($ins_query);
				}
        }              
}
?>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: danjenPosted on 2009-11-05 at 23:22:07ID: 25757261

This form is in the page Products_Insert.php and the database connection is set. All of the items in the form post to the database except for the sort fields that are in the array. The code you have posted above is on the page, but the items are not posting to the database.

 

by: seetharamlPosted on 2009-11-06 at 00:25:03ID: 25757503

Hi danjen,
can you print the insert query like below and let me know

print $ins_query;

Thanks

 

by: danjenPosted on 2009-11-06 at 09:57:53ID: 31650769

Thanks for all of your help. The print statement showed the the SKU field was missing the single quotes on insert. When I added that in, the statement worked perfect!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...