Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5839215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:33:18+00:00 2026-05-22T11:33:18+00:00

My spaces in text field get stored in mysql DB as ‘ name ‘

  • 0

My spaces in text field get stored in mysql DB as ' name ' which was just like ' name ' in UI. But when i display it to screen it gets displayed properly. but when i get count of the variable like strlen($var) it gives me count as 8 instead of 6. So any thing wrong like the way i am doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:33:18+00:00Added an answer on May 22, 2026 at 11:33 am

    This has all the hallmarks of a charset mismatch. This happens if your database is, for example, using an encoding of UTF8, but your web application is using an encoding of LATIN1. I’d suggest double-checking that the same encoding scheme is used throughout both your database tables and your application code. Also make sure that a SET NAMES query is run to explicitly set the charset.

    It’s also possible that if you’re connecting directly to the database with a client (SQLYog or somesuch), then that’s using a different encoding and displaying the data differently, even if both the web app in question and the database in question are using the same encoding.

    One more thing, strlen doesn’t handle encodings that use more than 1 byte per character very well. You should be using mb_strlen instead.

    https://www.php.net/manual/en/function.mb-strlen.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have field X that contains text with spaces in the end of the
How do I get empty spaces from the end of a varchar(513) field while
I have a text file which contains following Name address phone salary Jack Boston
I am getting new_tag from a form text field with self.response.get(new_tag) and selected_tags from
I'm trying to get my EditText field to not be as tall but to
I need to use C++ to read in text with spaces, followed by a
I'm having a noob issue. I have a long string of text (with spaces)
the text input only allows three words separated by spaces, and if it exceeds
It's very easy to set a text editor to use spaces or tab characters
I need change background of all text that have two spaces from the start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.