473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to create table for inserting mltiples values in one field?

I want to enter multiple checkbox values for parent_history field...for that i have created table...and did php code for inserting value in table...but it shows the Insertion Failed:error....i am not getting what is going wrong?? ,...
my code
Expand|Select|Wrap|Line Numbers
  1. <label>Asthma / Lung Problems</label>
  2.   <input  name="parent_history[]" type="checkbox" ckbox" value="Asthma / Lung Problems" tabindex="7" />
  3. <label>Cancer</label>
  4.  <input name="parent_history[]" type="checkbox"  value="Cancer" tabindex="8" />
  5.  
  6. $media_array = serialize($_POST['parent_history']);
  7.  
  8. $current_symptoms_array = serialize($_POST['current_symptoms']);
  9.  
  10. $sql_insert = "INSERT into `healthinfo`
  11.               (`member_id`, `full_name`, `age`, `height`, `weight`, `waist`, `forearms`, `biceps`, `hip`, `chest`, `parent_history`, `current_symptoms`, `tobacco`, `drugs`, `alcohol`, `outside_food`, `exercise`)
  12.             VALUES
  13.             ('$_SESSION[user_id]','$_SESSION[user_name]',$_POST[age]','$_POST[height]','$_POST[weight]','$_POST[waist]','$_POST[forearms]','$_POST[biceps]','$_POST[hip]','$_POST[chest]','$media_array'
  14.             ,'$current_symptoms_array','$_POST[tobacco]','$_POST[drugs]','$_POST[alcohol]','$_POST[outside_food]','$_POST[exercise]'";        
  15.   mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
Oct 19 '11 #1
1 1139
Dormilich
8,658 Expert Mod 8TB
there are several SQL syntax errors. I’ll post your SQL with added indenting, maybe you can spot the errors yourself.
Expand|Select|Wrap|Line Numbers
  1. $sql_insert = "
  2. INSERT into `healthinfo`
  3. (
  4.     `member_id`, 
  5.     `full_name`, 
  6.     `age`, 
  7.     `height`, 
  8.     `weight`, 
  9.     `waist`, 
  10.     `forearms`, 
  11.     `biceps`, 
  12.     `hip`, 
  13.     `chest`, 
  14.     `parent_history`, 
  15.     `current_symptoms`, 
  16.     `tobacco`, 
  17.     `drugs`, 
  18.     `alcohol`, 
  19.     `outside_food`, 
  20.     `exercise`
  21. )
  22. VALUES
  23. (
  24.     '$_SESSION[user_id]',
  25.     '$_SESSION[user_name]',
  26.     $_POST[age]',
  27.     '$_POST[height]',
  28.     '$_POST[weight]',
  29.     '$_POST[waist]',
  30.     '$_POST[forearms]',
  31.     '$_POST[biceps]',
  32.     '$_POST[hip]',
  33.     '$_POST[chest]',
  34.     '$media_array',
  35.     '$current_symptoms_array',
  36.     '$_POST[tobacco]',
  37.     '$_POST[drugs]',
  38.     '$_POST[alcohol]',
  39.     '$_POST[outside_food]',
  40.     '$_POST[exercise]'
  41. ";
Oct 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sascha | last post by:
Hi I need some help on achieving the following: I wrote a querie which collects Data out of three Tables, the Result looks like this: SET NOCOUNT ON DECLARE @ROW INT
2
by: Jim G | last post by:
I have two tables: TestA and TestB. Both tables have 3 fields: ID, Name, and RunDate. I need to create a query which will join the two tables first on Name but then I need to match up the...
8
by: cainlevy | last post by:
I'm wondering if there's any way to speed up create table queries? Besides upgrading hardware, that is. The very simplest table creation query, "create table table1 ( field1 INT(10))" is taking...
2
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
1
by: Philehof | last post by:
Hi Group. I would like to add some information to a query. I tried to create a table with the information from the query but then if i run the query again the additional data will be lost. ...
4
by: Jan | last post by:
Have an SQL create/import script. Running this on SQL would make it create a table with some values. Can Access2003 somehow use such and SQL script? I went into SQL query view to try it out, but...
2
by: Greg McLennan | last post by:
I am writing some Visual basic code that needs to create a M$ Access DB with a table that has a DATE ROW with dd/mm/yyyy in the Format as you would see in the general tab of the table-view. e.g...
12
by: GCM | last post by:
Hi, I have a table that has the following fields; LName, FName and MName. Also there are other fields in the table. I need to create another table with those fields combined as "Trim( & " " & &...
4
by: Priya | last post by:
Hey all, Is there a way to create a table in the SQL database by using an XML file as an input? I want to have an XML file which holds all the details of the table like the tablename, columns,...
2
by: genti1 | last post by:
Hi, I am kind of new with Access and I was wandering if someone could help me create a form where I can query data in a table by entering values in that form. For Example: I have a table...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.