PHP chr() returns diamond question mark from HTML -


i've read lot on subject, since it's quite popular problem, can't find solution...

i have html form in it...

<html>  <head>   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">   <?php    header('content-type: text/html; charset=utf-8');   ?>  </head>  <body>   <form method="post" accept-charset="utf-8">    <input type="password" name="pass">    <input type="submit">   </form>  </body> </html> 

...from password through $_post global , afterwards want split array of ascii values, each of changed standard arithmetic functions (+ / - / * ...) , afterwards changed numbers character ascii table ord function...

$password = $_post['pass']; $password = str_split($password); foreach($password $letter) {  $letter = ord($letter);  ..do algorithmic stuff number get..  $letter = chr($letter); } $password = implode('', $password); 

...final step - put mysql...

mysql_query('update some_table set password="'.$password.'" some_value=something'); 

problem? no matter how try split string (str_split, substr, mb_substr, preg_split, str_replace - explode etc) same result chr(53) (symbol displayed when displaying character can't interpreted utf-8) every symbol in both database , output in browser , doesn't matter if i'm using special characters or exclusive utf-8. i've tested standard english chars. note that:

  • i have put accept charset utf-8 in form
  • i'm sending headers through php saying utf-8
  • i've put in meta tags in html head tell browser utf-8
  • i'm using mb_internal_encoding utf-8
  • i saving .php files utf-8 without bom
  • the password field in mysql utf-8_general_ci
  • connection database set utf-8

i'm desperate right now. i'm sure there's embarassingly simple i've missed, please help...

edit

i switched places of ord() , chr() function calls intended. had made mistake , point ascii value(int) , afterwards convert number character of corresponding value in ascii table.

the thing is, on definition of these functions:

string chr(int) int ord(string) 

and using chr() on letter.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -