Page 1 of 1

Form submission oddities!

Posted: Wed Jan 03, 2007 8:24 am
by lettie_dude
Hi

Anyone ever come across this problem before.

I have a form that edits a news story the form populates fine from the database info. And all the required processing checks pass fine. However unless I actually change the first form input field and enter completely new data the form does not process and goes to my error message for unable to process.

For example:

The title of the story may be 'News Test 2'. This is the first input field on the form. Now unless this is changed to something else. i.e. 'News Test Two' the form will not work and the database is not updated.

I am going off my box here as the code is the same for every other form input field and it works fine if you change the title to something else! Anyone come across this perculiarity before?

Code: Select all

if(isset($_POST['newstitle'])) {

     if(eregi("^[a-zA-Z0-9 ]{5,50}$", trim($_POST['newstitle']))) {
	$clean['title'] = stripslashes($_POST['newstitle']);
     } else {
	$clean['title'] = FALSE;
	$msg .= '<p class="text"><font color="red">Please enter the news title!</font></p>';
     }

} else {
          $msg .= '<p class="text"><font color="red">Please enter the news title!</font></p>';
          $clean['title'] = FALSE;
}

Posted: Wed Jan 03, 2007 9:00 am
by feyd
No, I have not run into such a problem.

Care to post your form?

Posted: Wed Jan 03, 2007 10:34 am
by RobertGonzalez
Where's the rest of the processing code? I have run into problems with UPDATE queries where the data that is being updated has not changed, and, since I was checking against affected_rows(), the return from the DB was 0 and my error tiggered. It is not exactly the same as what you are going through, but I'd be interested to see all of the code.

Posted: Wed Jan 03, 2007 11:35 am
by lettie_dude
I'll re-jig the code for you and post a modified version so you can have a look at it.

Resolved

Posted: Thu Jan 04, 2007 2:56 am
by lettie_dude
Cheers Everah

Checked on the database submission and was also using affected_rows. I have resolved this myself but what solution did you put in place to combat this?

Posted: Thu Jan 04, 2007 10:38 am
by RobertGonzalez
I checked against two things instead of one. I ran the query through mysql_query(), then, if that did not error, I ran it through mysql_affected_rows(). If that did not return false, i proceeded with what I was doing, otherwise I did something else knowing the data never changed.