Jump to content

Recommended Posts

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]
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.
[!--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 \\.
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.