I'm trying to create a user system with PHP and mysql. I have made a table named userz in the database and set everything I need. My code 100% works as long as the hash does not generate any special characters, so it succeeds at random. I have tried setting the encoding in mysql to many kinds of utf-8 and i have tried header('Content-Type: text/html; charset=utf-8'); in my php script, but I can't get it to work!
$salt = mcrypt_create_iv(22, MCRYPT_DEV_URANDOM);
$enc= base64_encode($salt);
$hash = crypt($passwordz, $salt);
$qry = "INSERT INTO `userz` VALUES('0', '$fname', '$lname', '$email', '$hash', '$enc')";
mysql_query($qry) or die ($enc.$hash);
echo "Account created!";
It always dies and i'll see a character like this: �
Maybe I need to escape my query first? Any ideas? Thanks! (btw feel free to comment on any security problems if you see them).
The black-diamond-question-mark usually comes from