Inserted data gets a space between

TonyReba
TonyReba used Ask the Experts™
on
I am using a plugin to authenticate my users , I am modifyig it but somehow it is adding a huge white space between first and last name,,,

I am not sure, as dont know much about php, but is it anything here that might be causing this issue?
// to authenticate, the username must exist in the       if ($credentials['password'] ==  substr ($row->$passwordfield,-4) )
			
        {
            if (!empty($firstnamefield)){
                $fullname = $row->$firstnamefield;
            }
		
            if (!empty($lastnamefield)){
                $fullname .= ' '.$row->$lastnamefield;
            }

	            $response->fullname = $fullname;

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try using trim to eliminate excess spaces:

          if (!empty($firstnamefield)){
                $fullname = trim($row->$firstnamefield);
            }
            
            if (!empty($lastnamefield)){
                $fullname .= ' '. trim($row->$lastnamefield);
            }

                  $response->fullname = $fullname;

Author

Commented:
thanks that worked
No problem.  Thank you for the points!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial