phppup Posted March 1, 2012 Share Posted March 1, 2012 My database was working fine (for test purposes) a week ago. Now, it will not record data input from my forms. If I add a new record, it adds the record, but none of the data. If I update a record, it erases the values. The forms and attached scripts have NOT undergone any changes, and they DO provide SUCCESS messages. Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/ Share on other sites More sharing options...
floridaflatlander Posted March 1, 2012 Share Posted March 1, 2012 I would think something changed, can you post your sql code? What about the input to the variables for the sql, have you changed that? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322824 Share on other sites More sharing options...
phppup Posted March 1, 2012 Author Share Posted March 1, 2012 I will start posting code if I have to, but first, the only "adjustment" made to the actual database was that I may have added to columns (at various locations between others) and then I later deleted them. I have since replaced them as a troubleshooting technique, but their NAMES are NOT receiving any values (which is why I removed them in the first place). Does this sort of manuever affect the tables?? (I'm a newbie, so maybe I just messed it up... LOL) Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322832 Share on other sites More sharing options...
DavidAM Posted March 1, 2012 Share Posted March 1, 2012 The kind of problems that could be caused by adding or removing columns in a table would (most likely) not produce these symptoms -- they would likely produce errors, but the database would not be updated (or inserted). If your mySql (server software) was upgraded or the PHP engine (software) was upgraded; changes in the configuration could be affecting this. For instance: if register_globals was ON before and is now OFF any PHP code that depends on registered globals will fail. If you post the code that receives the form data we might be able to suggest some areas that may be causing problems. Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322850 Share on other sites More sharing options...
phppup Posted March 1, 2012 Author Share Posted March 1, 2012 CONNECT if(isset($_POST['action']) && $_POST['action'] == 'submitform') { $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; } $sql = "INSERT INTO pass (roastturkey,broccoli,brisket,carrots) VALUES ('$roastturkey','$broccoli','$brisket','$carrots')"; $result=mysql_query($sql); if($result){ echo "Successful"; }else { echo "ERROR"; } Fairly simple, I think, and it used to work. ** Disclaimer: Not responsible if this code causes hunger or urges to snack ** Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322852 Share on other sites More sharing options...
Pikachu2000 Posted March 1, 2012 Share Posted March 1, 2012 if(isset($_POST['action'])) is probably the problem. Unless the form has/had a field named 'action', either this code never worked, or something has changed. Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322856 Share on other sites More sharing options...
phppup Posted March 1, 2012 Author Share Posted March 1, 2012 It worked prviously with it (i think!), but i took it out and it seems to have repaired the problem. So what EXACTLY is that line saying? And is it necessary in one way or another as a double-check process of the form? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322858 Share on other sites More sharing options...
phppup Posted March 1, 2012 Author Share Posted March 1, 2012 WOW! found the same line of code in my UPDATE script. Took it out and I'm working fine now. Thanks a TON! (i think i'll quit while ahead... LOL) So what EXACTLY is that line saying? And is it necessary in one way or another as a double-check process of the form? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322860 Share on other sites More sharing options...
floridaflatlander Posted March 1, 2012 Share Posted March 1, 2012 Where was your update script at in relation to the above? And it may be just me but I'd put all that code in your "if (isset($_POST['action']) && $_POST['action'] == 'submitform')", that way it only runs if the if is true. Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322921 Share on other sites More sharing options...
phppup Posted March 1, 2012 Author Share Posted March 1, 2012 I'm stillnot exactly sure that I understand EXACTLY what that first line is COMMANDING. (as a newbie, some code just ends up in my script because a resource SAID it SHOULD be there, and NOT because i FULLY understand WHY i would WANT it there) Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322929 Share on other sites More sharing options...
floridaflatlander Posted March 1, 2012 Share Posted March 1, 2012 if (isset($_POST['action']) && $_POST['action'] == 'submitform')", isset checks to see if $POST['action'] has a value so you're basiclly saying, if (action has a value) & (that value equals submitform) run the following script heres how I do my submits f (isset($_POST['submit'])){ $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; $sql = "INSERT INTO pass (roastturkey,broccoli,brisket,carrots) VALUES ('$roastturkey','$broccoli','$brisket','$carrots')"; $result=mysql_query($sql); if($result){ echo "Successful"; }else { echo "ERROR"; } } // end of it this is my button <input type="submit" name="submit" value="Submit" /> Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322931 Share on other sites More sharing options...
phppup Posted March 2, 2012 Author Share Posted March 2, 2012 But what's the benefit of having it versus not using anything?? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322935 Share on other sites More sharing options...
phppup Posted March 2, 2012 Author Share Posted March 2, 2012 And why would someone want the redundancy of the statement the way I had originally copied it? Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322937 Share on other sites More sharing options...
floridaflatlander Posted March 2, 2012 Share Posted March 2, 2012 And why would someone want the redundancy of the statement the way I had originally copied it? Are you talking about the "if (isset($_POST['action']) && $_POST['action'] == 'submitform')". ? I don't know, I do this with my sessions but not my submit POST Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322939 Share on other sites More sharing options...
Pikachu2000 Posted March 2, 2012 Share Posted March 2, 2012 WOW! found the same line of code in my UPDATE script. Took it out and I'm working fine now. Thanks a TON! (i think i'll quit while ahead... LOL) So what EXACTLY is that line saying? And is it necessary in one way or another as a double-check process of the form? I don't know if it's necessary or not. You haven't posted the form, so my answer was nothing more than a semi-educated guess. Quote Link to comment https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/#findComment-1322992 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.