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 8118349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:27:38+00:00 2026-06-06T04:27:38+00:00

a bit of a PHP / MySQL newbie here… I’ve been building a PHP-based

  • 0

a bit of a PHP / MySQL newbie here…

I’ve been building a PHP-based site that uses a MySQL database for storing user information, like their display names, usernames, and passwords.

I’ve been learning about escaping, prepared statements and the like, and how to prevent SQL injections like “bobby’); drop table users–“.

I’m using PDO prepared statements to get user input from forms, in order to register them into the DB. However, I need to know a few things:

  1. Since I am using prepared statements, for display names, usernames,
    passwords, etc, is it okay for me to allow special characters like
    @, #, $, or even ‘single’ or “double” quotes? And what about spaces,
    international characters, characters with accents, or things like ♥
    ? And when I ask if it’s “okay” to allow these characters, I’m
    wondering if there are any further security risks that may arise
    from allowing quotes or parentheses in people’s usernames, or things
    like html tags for bold or italics?

  2. If it is okay to allow most special characters, but not some: are
    there any specific “dangerous” characters (in the scope of MySQL)
    which I absolutely need to make illegal? (I feel like quotes may fit
    this agenda, but I’m getting mixed signals on that.)

  3. If I were to allow characters outside of the typical “alphanumeric
    and underscore” range, are there any pitfalls I may experience later
    (in MySQL, SQL, or PHP) from allowing strange characters? Will I
    need to somehow make html tags appear as strings, rather than actual
    tags, when displaying people’s usernames? Or would I need to escape
    quotes in people’s usernames whenever I wanted to query with them?
    Or does none of this matter since I’ll be using prepared statements
    with PDO?

  4. Do charsets like utf8 or utf16 come in anywhere, in making it so I
    can accept the widest range of display names and usernames, while
    still making sure those alphabets can be rendered on my website?

  5. I know that there are some Cyrillic letters that look identical to
    English ones. I used to copy these straight out of MS Word and use
    them in my usernames. I realize that these can be used to
    perceptually-impersonate other members, simply by swapping out an
    English “a” for a Cyrillic “a”. Usernames with ♥ in them may be hard
    to search for if someone isn’t well-versed in alt-code. Should this
    be a concern? What is your opinion on this?

Thanks in advance to whoever can give me some insight on this.

  • 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-06-06T04:27:39+00:00Added an answer on June 6, 2026 at 4:27 am

    First let me say that I really like your style. It appears that most people don’t take the time to think these things through, and just slap together queries with no data sanitization at all. So congratulations on being diligent. 🙂

    That said, with PDO, you shouldn’t have to to worry about quotes messing up your queries. Especially if you bind your variables with bindParam, which allows strict parameter control. With that you can cast the variable type, and length. Also, special characters will not mess up your query, as PDO escapes them, too. So no need to worry about that.

    As for making HTML appear as text instead of actual HTML, a very useful function is htmlspecialchars(), which will convert html code to character codes. This function can also be used with the optional ENT_QUOTES flag, which turn this " into this ". htmlspecialchars() also has an option to set the output to the encoding of your choice.

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

Sidebar

Related Questions

I currently have a news website setup in PHP/MYSQL that's a bit old and
I'm a bit obsessed now. I'm writing a PHP-MYSQL web application, using PDO, that
I'll preface by stating that I am a bit new to PHP and MySQL.
IS this bit of code in PHP/mysql considered a stored procedure? $sql = 'SELECT
I've done a fair bit of mysql php programming but am pretty new to
I need to delete some data from mysql. I know a bit of php
The only similar question I have found is: Insert php boolean into mysql bit
is there a possible bit of code (php, java, css, html) that will force
I'm a bit of a PHP newbie so go easy on me :) I
I am a little bit new to the PHP/MYSQL arena, and had an idea

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.