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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra space after variable

Status
Not open for further replies.

inteleserve

IS-IT--Management
Dec 13, 2002
75
US
I have a form where have the user enters their username.

But when I check the Request.form("login_username") against the objrs("username") in my table they don't match because the one pulled from the table has a space after it.

I found the space by doing a Response.Write objrs("username") multiple times like this.

Response.Write objrs("username")
Response.Write objrs("username")
Response.Write objrs("username")

The output looks like this:
myusername myusername myusername
Rather than:
myusermynameusermynameusername

Then the problem is:
Response.Write Request.form("login_username")
Response.Write objrs("username")
Response.Write Request.form("login_username")
Response.Write objrs("username")
Response.Write Request.form("login_username")
Response.Write objrs("username")
Will output:
myusernamemyusername myusernamemyusername myusernamemyusername
 

Wrong forum perhaps? This is a Visual FoxPro forum on Web realted issues.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Perhaps... but I am using an ocbc connection to a Visual Foxpro database and the variable is output to a web page using asp and an sql string. So I thought this would be the right place... any sugestions on where to post is not here?

Do you know of any Visual Foxpro settings for padding?
 

The problem as you state it is:

Then the problem is:
Response.Write Request.form("login_username")
Response.Write objrs("username")


This is not VFP code. So I'm not sure.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In VFP there's an ALLTRIM() function you can use to trim leading and trailing spaces from any string. Since the code you are using is not VFP, I don't know what you should use, but there is probably a similar function you could call before doing your comparison. You need to post this message in the appropriate forum for the language you are using when you do the comparison.



-BP (Barbara Peisch)
 
I am able to solve the problem with the trim function..

Response.Write (trim(objrs("username")))

But I was just wondering if there is a known setting in VFP that would cause a space like i am seeing... I guess I'll keep my eyes open for another solution, but for now the trim function has solved my problem.
 
I'm curious: What product are you using?

VFP method call syntax requires parentheses, so your:
Response.Write Request.form("login_username")

would be:
Response.Write( Request.form("login_username") )

I know VB requires not using the parentheses unless the result is being assigned to something, but perhaps you are using a VFP COM object from within VB?

If so, is it your COM object, or a 3rd party application?

 
inteleserve said:
and the variable is output to a web page using asp and an sql string

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Ah, I missed that post. BPeisch gave the whole answer, then.... "objrs" must stand for an 'object Record Set'.
 
Hi Inteleserve,

Looking to the posts I guess "objrs" must be an record set like wgcs said.

I guess you used a query to lookup the VFP database to check if the user exists. In the "where" clause you can then use the vfp function "alltrim()" as mentioned above (and even "upper()" for upper case words) your statement would look something like this:
Code:
sql = "select * from myUserTable where allTrim(" _
& Request.form("login_username") & ") = allTrim(username)"

I hope it will clear some things out for you.


Charl
 
While this may not hold in this instance, I have had a problem with a NULL being added to some strings in VFP 8.0. The Alltrim() did not remove it. I'm forced to use a Strtran() to replace the Char(0) with ''. Nutty, but it works. I've not been able to determine why some functions, such as the GetDir() randomly add a null to the end of the string.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top