0

How can I submit any kind of symbols to php and update it into my database tables? When I use some symbols ('!@#$%^&*()_+=), it does not update the database table. Can anybody help me?

Muhammad
  • 3,169
  • 5
  • 41
  • 70
  • 3
    `htmlentities()` http://www.php.net/manual/en/function.htmlentities.php – Realitätsverlust Feb 10 '14 at 09:28
  • Given that you have tagged this question both [tag:jquery] and [tag:mysql], when you say "*the data table*" are you referring to a jQuery data table or a MySQL data table? – eggyal Feb 10 '14 at 09:36
  • 1
    `htmlentities`? What does HTML have to do with SQL? The OP just needs to use prepared statements and do proper error checking. But there's no way to answer a question that only says that some undisclosed code does not work. – Álvaro González Feb 10 '14 at 09:45
  • check this link http://stackoverflow.com/questions/4803354/how-do-i-insert-a-special-character-such-as-into-mysql – krishna Feb 10 '14 at 10:00

3 Answers3

1

You can use the htmlspecialchars() in which you can find the documentation here.

http://us.php.net/htmlspecialchars

vahnevileyes
  • 415
  • 3
  • 6
  • I used this in my php and it works well. Thanks define('CHARSET', 'ISO-8859-1'); define('REPLACE_FLAGS', ENT_COMPAT | ENT_XHTML); – user3178876 Feb 10 '14 at 10:07
0

Use function htmlentities() The values will not be stored in the database as they are like ('!@#$%^&*()_+=) but this function will change your " to " and other characters respectively.

Keep aware yourself of SQL Injection and XSS. If you do not filter your inputs properly then your code will be vulnerable to script kiddies.

Noman Riffat
  • 187
  • 2
  • 2
  • 16
-2

You could use the htmlentities() function. It's the best solution I think. If you really really don't want to use this function for some reason you can always change the column type to text instead of varchar.

Edit: sorry for using the wrong function. You guys are right. Maybe mysql_real_escape_string() does the job but probably it would only take care of the quotations.