wardweb Posted June 2, 2006 Share Posted June 2, 2006 I have a simple form to submit data to a local MySQL database. It uses the "post" method to call an acknowledgment page, which uses PHP to connect to the DB and update fields in a table.When I fill in either/both form fields and click Submit, nothing happens; no page change, no change to the DB. But if I leave the form fields blank and click Submit, the DB is updated and the acknowledgment page appears as it should.The DB table is "URLs".I've checked the syntax many times, but I suspect the problem may lay in my SQL query code. Here's a snippet of it:[code]//Set the variables for the DB queries:$queryOverallProductionStatus = "UPDATE URLs SET stable_url = '{$_POST['OverallProductionStatus']}' WHERE document = 'Overall Production Status'";$rOPS = mysql_query ($queryOverallProductionStatus);//Print error message if query not successful.echo mysql_error();$query747ProductionStatus = "UPDATE URLs SET stable_url = '{$_POST['747ProductionStatus']}' WHERE document = '747 Production Status'";$r7PS = mysql_query ($query747ProductionStatus);//Print error message if query not successful.echo mysql_error(); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11050-submitting-data-gets-no-result-submitting-blanks-works/ Share on other sites More sharing options...
AndyB Posted June 2, 2006 Share Posted June 2, 2006 Serious stupid questions:#1 - you do have the same code under test on a server as you think you do, right?#2 - you have not turned off all error reporting, right?When in doubt, echo some stuff to see what's really happening (which isn't necessarily what you think ought to happen). Change your code typically to something like this for each query:[code]$queryOverallProductionStatus = "UPDATE URLs SET stable_url = '{$_POST['OverallProductionStatus']}' WHERE document = 'Overall Production Status'";echo $$queryOverallProductionStatus. "<br>"; // see what we tried$rOPS = mysql_query ($queryOverallProductionStatus) or die("Error: ". mysql_error());//Print error message if query not successful.// echo mysql_error();[/code]Tell us what happened with that type of change. Quote Link to comment https://forums.phpfreaks.com/topic/11050-submitting-data-gets-no-result-submitting-blanks-works/#findComment-41290 Share on other sites More sharing options...
wardweb Posted June 2, 2006 Author Share Posted June 2, 2006 [!--quoteo(post=379454:date=Jun 2 2006, 02:50 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 2 2006, 02:50 PM) [snapback]379454[/snapback][/div][div class=\'quotemain\'][!--quotec--]Serious stupid questions:#1 - you do have the same code under test on a server as you think you do, right?#2 - you have not turned off all error reporting, right?When in doubt, echo some stuff to see what's really happening (which isn't necessarily what you think ought to happen). Change your code typically to something like this for each query:[code]$queryOverallProductionStatus = "UPDATE URLs SET stable_url = '{$_POST['OverallProductionStatus']}' WHERE document = 'Overall Production Status'";echo $$queryOverallProductionStatus. "<br>"; // see what we tried$rOPS = mysql_query ($queryOverallProductionStatus) or die("Error: ". mysql_error());//Print error message if query not successful.// echo mysql_error();[/code]Tell us what happened with that type of change.[/quote]Thanks for your quick reply, Andy. In the "file" fields I had been typing random strings to test the code, instead of using the Browse button to select a file. I tried using the Browse buttons and suddenly all is well; the database is updated and the acknowledgement page appears as it should.I've used "file" fields before successfully, but I didn't know they fail unless the correct syntax is used in them. Experimenting, it looks as if the string needs to begin with a letter and a colon, or \, or \\. Quote Link to comment https://forums.phpfreaks.com/topic/11050-submitting-data-gets-no-result-submitting-blanks-works/#findComment-41314 Share on other sites More sharing options...
AndyB Posted June 2, 2006 Share Posted June 2, 2006 Oh, good. I was slightly baffled as to why what looked like perfectly functional code wasn't working. One good thing is that now you know the script needs to include error trapping for blank or phoney file field data so that it doesn't write to the database in those circumstance. Quote Link to comment https://forums.phpfreaks.com/topic/11050-submitting-data-gets-no-result-submitting-blanks-works/#findComment-41318 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.