benjamin_boothe Posted August 22, 2006 Share Posted August 22, 2006 The form successfully adds a record to the database.BUT.... it doesn't add what I put in the form, instead it adds 'NULL' to all of fields.So it looks like this:[img]http://localhost/policy_records.gif[/img]Is it beacuse the default value is NULL on all fields barring the id?If so, what can I do about that? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 22, 2006 Share Posted August 22, 2006 [quote]If so, what can I do about that?[/quote]Fix your code. Or post the offending part, and maybe we can help. Quote Link to comment Share on other sites More sharing options...
benjamin_boothe Posted August 22, 2006 Author Share Posted August 22, 2006 [code] if ($msg=="") { $insert = "INSERT INTO policy_holder ( id, title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email) VALUES ( NULL, '$t', '$fn', '$sn', '$dob', '$uk', '$ms', '$d', '$es', '$ad1', '$a', '$tn', '$c', '$pc', '$tw', '$th', '$fax', '$em')";[/code]That is the query I am running. I echoed it to see what it is doing:[quote]INSERT INTO policy_holder ( id, title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email) VALUES ( NULL, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')[/quote]It's not returning the values in the db that I am putting into my form. Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 22, 2006 Share Posted August 22, 2006 Please post the code where you set your form variables, and your form code... ;) Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 22, 2006 Share Posted August 22, 2006 If that is the insert query, then you aren't inserting anything into the database..... Quote Link to comment Share on other sites More sharing options...
benjamin_boothe Posted August 22, 2006 Author Share Posted August 22, 2006 Thanks a lot HeyRay2.I've been stressing like a muthafucka over dat shit!!It was staring at me right in the face. Lack of sleep!!!Dis PHP shit has become an addiction man!!!I can't thank you enough bro' Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 22, 2006 Share Posted August 22, 2006 Could we inquire as to what was causing your issue, in case another forum member comes across a similar problem? ;) Quote Link to comment Share on other sites More sharing options...
benjamin_boothe Posted August 23, 2006 Author Share Posted August 23, 2006 Because the globals are off I had to use this piece of code. This was because at first, I was getting 'Notice: Undefined' messages. So I had to declare all of my variables like this:[code]$t = isSet($_POST['title']) ? $_POST['title'] : '';$fn = isSet($_POST['first_name']) ? $_POST['first_name'] : '';$sn = isSet($_POST['surname']) ? $_POST['surname'] : '';$dob = isSet($_POST['date_of_birth']) ? $_POST['date_of_birth'] : '';$uk = isSet($_POST['uk_residency']) ? $_POST['uk_residency'] : '';$ms = isSet($_POST['marital_status']) ? $_POST['marital_status'] : '';$d = isSet($_POST['disability']) ? $_POST['disability'] : '';$es = isSet($_POST['employment_status']) ? $_POST['employment_status'] : '';$ad1 = isSet($_POST['address_line_1']) ? $_POST['address_line_1'] : '';$a = isSet($_POST['area']) ? $_POST['area'] : '';$tn = isSet($_POST['town']) ? $_POST['town'] : '';$c = isSet($_POST['county']) ? $_POST['county'] : '';$pc = isSet($_POST['post_code']) ? $_POST['post_code'] : '';$tw = isSet($_POST['telephone_work']) ? $_POST['telephone_work'] : '';$th = isSet($_POST['telephone_home']) ? $_POST['telephone_home'] : '';$fax = isSet($_POST['fax_number']) ? $_POST['fax_number'] : '';$em = isSet($_POST['email']) ? $_POST['email'] : '';[/code]Beforehand I was declaring the variable like this:For example, if wanted to declare the 'fax_number' form variable, I was doing this:[code]$fax = isSet($_POST['fax']) ? $_POST['fax'] : '';[/code]Which was why it was not reading the values that I was inputting, as I was not making the field names (form inputs) equal to the variables like this:[code]$fax = isSet($_POST['fax_number']) ? $_POST['fax_number'] : '';[/code]That was the issue all along!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.