Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form returning a comma at the end of a field name - ideas ? 1

Status
Not open for further replies.

PeterMac

Programmer
Mar 9, 2001
51
CA
This code:

strFirstName = Trim(Request.Form("First_name"))
strQuery = "UPDATE people SET first_name = '" & strFirstName

returns this string... any idea where the comma comes from at the end ...?

UPDATE people SET first_name = 'Nqqqasimxy,

I have determined that it is in the variable itself, but can't figure out why it is there... I don't see it on the form before it is submitted... any help appreciated.

Peter
 
i suppose you cut/paste something incomplete:
you are missing "'" at the end of the strQuery.

strQuery = "UPDATE people SET first_name = '" &_
strFirstName & "'"

and normally you should add a UDF FixQuotes function (search Tek-Tips for that),
because your update will crash with a ' in a firstname.

br
Gerard
(-:

Better a known bug then a new release.
 
Yes I know that part about the closing quote, I am wanting to know about the mysterious comma at the end of what I have posted... any ideas there?

This is what I get when I add the ending quote... the comma is still there? grrrr !

UPDATE people SET first_name = 'Nasimxy,'

Peter
 
I have extended my code to other fields and they work... the value for prefix does not have a comma within the quotes like firstname does... this is a puzzlement to me...
and no there is no comma in the database data itself, I checked that too...

strQuery = "UPDATE people SET prefix = '" & strPrefix & "', first_name = '" & strFirstName & "'"


UPDATE people SET prefix = 'Mr.', first_name = 'Nabcasimxy,'

and here are my form definitions for the variables...

<input type=&quot;text&quot; name=&quot;prefix&quot; size=&quot;20&quot;
Value = &quot;<%= objRS(&quot;prefix&quot;) %>&quot; >

<input type=&quot;text&quot; name=&quot;first_name&quot; size=&quot;20&quot;
Value = &quot;<%= objRS(&quot;first_name&quot;) %>&quot; >
 
your code snippet does not tell us how you get the value for
strPrefix and strFirstName ....


br
Gerard
(-:

Better a known bug then a new release.
 
why does that matter? I am in &quot;update&quot; mode... I am entering information into the given fields that just happen to have an original value. the form simply returns the values to the page and I start picking up the values and trying to update back to the database... the information could all be new for all I (the developer) know...

I suspect it is in the naming of the variable itself, so I will be trying out a few things and then post back here in a little while with the answers that I may find.

Peter
 
sorry for asking!
but in

strQuery = &quot;UPDATE people SET prefix = '&quot; & strPrefix & &quot;', first_name = '&quot; & strFirstName & &quot;'&quot;

you use strPrefix and strFirstname to build your strQuery.
You enter data in a field named &quot;first_name&quot;, but you use the strFirstName to build the query....

so i presume you have something like:

dim strFirst_name
strFirst_name = request.form(&quot;first_name&quot;)

etc...

this code runs fine on my server...




br
Gerard
(-:

Better a known bug then a new release.
 
yes... as seen in the first message posted on this subject... I hope this isn't coming across as being rude? I am just frustrated with this matter. Thanks for the pointers so far...

Peter
 
it's gone !

UPDATE people SET prefix = 'Mr.', first_name = 'Nasimxy'

the only thing I changed was removing the underscore from the forms input name... any thoughts on the effect there?

<input type=&quot;text&quot; name=&quot;prefix&quot; size=&quot;20&quot;
Value = &quot;<%= objRS(&quot;prefix&quot;) %>&quot; >

<input type=&quot;text&quot; name=&quot;firstname&quot; size=&quot;20&quot;
Value = &quot;<%= objRS(&quot;first_name&quot;) %>&quot; >
 
Do you have another input somewhere also named &quot;first_name&quot;?

Sometimes I get the comma problem when I have two input values named the same. It's appends the second value at the end. In your case there's nothing there, but it appends the blank value anyway.

Usually it happens when I accidentely :) do something like this:

<input type=&quot;text&quot; name=&quot;this&quot; value=&quot;value&quot;>
<input type=&quot;hidden&quot; name=&quot;this&quot; value=&quot;&quot;>

and when I do a Request.Form(&quot;this&quot;) on another page it returns &quot;value,&quot;.

HTH
Earme
 
THANK YOU VERY MUCH! that is what was happening... I copied my orginal input field once the attributes were set and then thought that I had changed all the names... lesson learned !

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top