Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] Data not submitting to database...


[SOLVED] Data not submitting to database...

Reply
  #1 (permalink)  
Old 01-02-09, 12:21 PM
Jambone Jambone is offline
Newbie Coder
 
Join Date: Oct 2008
Location: Solihull, UK
Posts: 45
Thanks: 1
Thanked 0 Times in 0 Posts
[SOLVED] Data not submitting to database...

PHP Code:

<?

if($_SESSION['madcow']) {
?>
<form method="POST">
<font color="red">*</font>Name: <input type="text" name="name" /><br /><br />
<font color="red">*</font>Gender: <select name="gender" />
<option value="M">Male</option>
<option value="F">Female</option>
</select><br /><br />
<font color="red">*</font>Age: <input type="text" name="age" /><br /><br />
<b>Personal Information:</b><br /><br />
<font color="red">*</font>Height:<input type="text" name="height" /> feet & inches<br /><br /> 
<font color="red">*</font>Dress Size:<input type="text" name="dresssize" /><br /><br />
<font color="red">*</font>Chest/Bust:<input type="text" name="chest" /> inches<br /><br />
<font color="red">*</font>Bra Size:<input type="text" name="bra" /><br /><br />
<font color="red">*</font>Waist:<input type="text" name="waist" /> inches<br /><br />
<font color="red">*</font>Hips:<input type="text" name="hips" /> inches<br /><br />
<font color="red">*</font>Inside Leg:<input type="text" name="insideleg" /> inches<br /><br />
<font color="red">*</font>Eye Colour:<input type="text" name="eyecolour" /><br /><br />
<font color="red">*</font>Hair Colour:<input type="text" name="haircolour" /><br /><br />
<font color="red">*</font>Hat Size:<input type="text" name="hatsize" /><br /><br />
<font color="red">*</font>Shoe Size:<input type="text" name="shoesize" /><br /><br />
<font color="red">*</font>Nationality:<input type="text" name="nationality" /><br /><br />
<font color="red">*</font>Native Accent:<input type="text" name="nativeaccent" /><br /><br />

<p align="center"><b>Work Preferences:</b></p>
<b>Preferred Area of Work:</b><br />
    <input type="checkbox" name="option1" value="Photography" /> Photography
    <input type="checkbox" name="option2" value="Catwalk/Showroom" /> Catwalk/Showroom
    <input type="checkbox" name="option 3" value="Promotional" /> Promotional
    <input type="checkbox" name="option 4" value="Video" /> Video
    <input type="checkbox" name="option 5" value="Adult" /> Adult
    <br />
    <br />
<b>Preferred Style of Work:</b><br />
    <input type="checkbox" name="option6" value="Fashion" />Fashion - Fashion/Advertising/Non-glamour - Normal Clothing<br /><br />
    <input type="checkbox" name="option7" value="Glamour" />Glamour - Clother Glamour - Lingerie, swimwear ect.<br /><br />
<input type="checkbox" name="option8" value="Swimwear/Lingerie" />Swimwear/Lingerie - Lingerie, swimwear ect.<br /><br />
    <input type="checkbox" name="option9" value="Body Parts" />Body Parts - Hands, feet or and body part required (not breasts or nude)<br /><br />
    <input type="checkbox" name="option10" value="Hair" />Hair - Self Explanatory<br /><br />
    <input type="checkbox" name="option11" value="Gothic or Fetish" />Gothic or Fetish - More provocative outfits<br /><br />
    <input type="checkbox" name="option12" value="Topless" />Topless - Showing breasts and nipples<br /><br />
    <input type="checkbox" name="option13" value="Classic/Artistic Nude" />Classic/Artistic Nude - Completely nude with legs together<br /><br />
    <input type="checkbox" name="option14" value="UK Nude" />UK Nude - Nude open-leg work as in UK top-shelf magazines<br /><br />
<input type="checkbox" name="option15" value="US Nude" />US Nude - Like US Magazine with the labia held open<br /><br />
    <input type="checkbox" name="option16" value="Continental Nude" />Continental Nude - Hardcore Photography - including interaction with other models<br /><br />
    Other (please specify): <input type="text" name="option17"/><br /><br />
<b>Pictures</b><br /><br />
Picture one: <input type="text" name="Pic1" /><br /><br />
Picture two: <input type="text" name="Pic2" /><br /><br />
    <input type="submit" value="Submit" name="submit" />

<?
require('mysql_connect.php');
$submit $_POST['submit'];

       if(
$submit) {
        
$Name $_POST['name'];
        
$Gender $_POST['gender'];
        
$Age $_POST['age'];
        
$Height $_POST['height'];
        
$DressSize $_POST['dresssize'];
        
$Chest $_POST['chest'];
        
$Bra $_POST['bra'];
        
$Waist $_POST['waist'];
        
$Hips $_POST['hips'];
        
$InsideLeg $_POST['insideleg'];
        
$EyeColour $_POST['eyecolour'];
        
$HairColour $_POST['haircolour'];
        
$HatSize $_POST['hatsize'];
        
$ShoeSize $_POST['shoe size'];
        
$Nationality $_POST['nationality'];
        
$NativeAccent $_POST['nativeaccent'];
        
$Option1 $_POST['option1']; //Photography
        
$Option2 $_POST['option2']; //Catwalk/Showroom
        
$Option3 $_POST['option3']; //Promotional
        
$Option4 $_POST['option4']; //Video
        
$Option5 $_POST['option5']; //Adult
        
$Option6 $_POST['option6']; //Fashion
        
$Option7 $_POST['option7']; //Glamour
        
$Option8 $_POST['option8']; //Swimwear/Lingerie
        
$Option9 $_POST['option9'];//Body Parts
        
$Option10 $_POST['option10']; //Hair
        
$Option11 $_POST['option11']; //Gothic or Fetish
        
$Option12 $_POST['option12']; //Topless
        
$Option13 $_POST['option13']; //Classic/Artistic Nude
        
$Option14 $_POST['option14']; //UK Nude
        
$Option15 $_POST['option15']; //US Nude
        
$Option16 $_POST['option16']; //Continental Nude
        
$Option17 $_POST['option17']; //Other
        
$Pic1 $_POST['Pic1']; //Pic1
        
$Pic2 $_POST['Pic2']; //Pic2
        
$Pic3 $_POST['Pic3']; //Pic3
        
$Pic4 $_POST['Pic4']; //Pic4
        
$Pic5 $_POST['Pic5']; //Pic5
        
        
MYSQL_QUERY("INSERT INTO `Models` (Name, Gender, Age, Height, Dress Size, Chest, Bra, Waist, Hips, Inside Leg, Eye Colour, Hair Colour, Hat Size, Shoe Size, Nationality, Native Accent, Photography, Catwalk/Showroom, Promotional, Video, Adult, Fashion, Glamour, Swimwear/Lingerie, Body Parts, Hair, Gothic or Fetish, Topless, Classic/Artistic Nude, UK Nude, US Nude, Continental Nude, Other, Pic1, Pic2) VALUES ('$Name','$Gender','$Age','$Height','$DressSize','$Chest','$Bra','$Waist','$Hips,'$InsideLeg','$EyeColour','$HairColour,'$HatSize','$ShoeSize','$Nationality','$NativeAccent','$Option1','$Option2','$Option3','$Option4','$Option5','$Option6','$Option7',$Option8','$Option9','$Option10','$Option11','$Option12','$Option13','$Option14','$Option15','$Option16','$Option17','$Option18','$Pic1','$Pic2','$Pic3','$Pic4','$Pic5')");
        echo 
'Model Added to Database';
        }
        } else  {
        echo 
'Please Login';
        }
Not a clue why it wont work, advice would be much appreciated
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-02-09, 12:49 PM
php4newbies php4newbies is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
First do some debugging:
PHP Code:

MYSQL_QUERY("INSERT INTO `Models` (Name, Gender, Age, Height, Dress Size, Chest, Bra, Waist, Hips, Inside Leg, Eye Colour, Hair Colour, Hat Size, Shoe Size, Nationality, Native Accent, Photography, Catwalk/Showroom, Promotional, Video, Adult, Fashion, Glamour, Swimwear/Lingerie, Body Parts, Hair, Gothic or Fetish, Topless, Classic/Artistic Nude, UK Nude, US Nude, Continental Nude, Other, Pic1, Pic2) VALUES ('$Name','$Gender','$Age','$Height','$DressSize','$Chest','$Bra','$Waist','$Hips,'$InsideLeg','$EyeColour','$HairColour,'$HatSize','$ShoeSize','$Nationality','$NativeAccent','$Option1','$Option2','$Option3','$Option4','$Option5','$Option6','$Option7',$Option8','$Option9','$Option10','$Option11','$Option12','$Option13','$Option14','$Option15','$Option16','$Option17','$Option18','$Pic1','$Pic2','$Pic3','$Pic4','$Pic5')") or die(mysql_error()); 

I've added :
PHP Code:

or die(mysql_error()); 

But just looking really quickly I've noticed you have field names like 'Inside Leg' is that really what your field name is in your database? or is it 'inside_leg'?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-02-09, 12:51 PM
Jambone Jambone is offline
Newbie Coder
 
Join Date: Oct 2008
Location: Solihull, UK
Posts: 45
Thanks: 1
Thanked 0 Times in 0 Posts
Will do the debug Thanks

Also, definitely spaces
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-02-09, 12:56 PM
Jambone Jambone is offline
Newbie Coder
 
Join Date: Oct 2008
Location: Solihull, UK
Posts: 45
Thanks: 1
Thanked 0 Times in 0 Posts
Got this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Size, Chest, Bra, Waist, Hips, Inside Leg, Eye Colour, Hair Colour, Hat Size, Sh' at line 1

?? Not sure what it could be.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-02-09, 01:07 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
I'm not sure, but it's possible that you need quotes around the columns that are two words (like "Native Accent') or maybe the forward slashes are causing the problem (like in 'Swimwear/Lingerie').
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-02-09, 01:32 PM
Jambone Jambone is offline
Newbie Coder
 
Join Date: Oct 2008
Location: Solihull, UK
Posts: 45
Thanks: 1
Thanked 0 Times in 0 Posts
Bah, still erroring - will keep trying

Last edited by Jambone; 01-02-09 at 01:39 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-02-09, 01:33 PM
php4newbies php4newbies is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Jambone View Post
Got this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Size, Chest, Bra, Waist, Hips, Inside Leg, Eye Colour, Hair Colour, Hat Size, Sh' at line 1

?? Not sure what it could be.
check your database and reply with the field names. Make sure Size, Chest, Bra, Waist, Hips, Inside Leg, Eye Colour, Hair Colour, Hat Size etc... are all fields in your database and make sure they are all spelled correctly. Also in the future you really want to use all lower case with underscores for spaces when naming database tables and fields. Or use camel case. ie inside_leg or insideLeg as field names.

It looks like that is the issue since your error starts at Size. it should be Dress Size correct? So it may not be working since you have a space between Dress and Size. I would suggest renaming all your fields now to dress_size, inside_leg etc.. then modifying your php code to use those names. It's work but it'll work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-02-09, 01:40 PM
php4newbies php4newbies is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Okay, I looked it up you can use spaces (no restrictions on the mysql side) in field names but it is considered bad practice and I googled 'php spaces in mysql field name' and their are tons of other people with the same issue. Again, I would recommend changing the field names.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 01-02-09, 01:55 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Found it

1) Missing quote before "$Option8"

'$Option7',$Option8',


2) Also one missing after $Hips

'$Hips,'$InsideLeg'


3) And after $HairColour:

,'$HairColour,'$HatSize'
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]

Last edited by End User; 01-02-09 at 01:59 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 01-02-09, 02:18 PM
Jambone Jambone is offline
Newbie Coder
 
Join Date: Oct 2008
Location: Solihull, UK
Posts: 45
Thanks: 1
Thanked 0 Times in 0 Posts
It worked dude! Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submitting form sends file, but not $_POST data, to database GodsHand PHP 1 03-30-06 12:38 PM
Can not insert data to database trod ASP 5 07-20-05 09:13 AM
Script for uploading data from local database to production database pual_cruzs PHP 1 07-06-04 01:44 AM


All times are GMT -5. The time now is 08:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.