Greetings:
I have a regex that goes through some source code and finds 3 - Attached and stores it as $garage_spaces. If I then do an echo $garage_spaces, I don't have the but just a space. That's fine enough. When I insert this into a MySQL table, it just looks like "3 - Attached" which is again fine. However, when I do a select and pull the garage field, I get weird ascii characters instead of the spaces. It looks like 3�-�Attached for some reason. It is driving me nuts! Anybody know what I'm doing wrong or what I could try to do to fix this?
Thank you so much!
PHP/MySQL storing unusual characters!
Moderator: General Moderators
Re: PHP/MySQL storing unusual characters!
I'm not entirely sure what you're trying to accomplish, but when those � characters show up, it's a good sign you've got your encoding wrong somewhere.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: PHP/MySQL storing unusual characters!
Thanks for the reply. I have my database set as utf8 and I'm developing locally on my Mac using MAMP. Where else would the encoding be off?pickle wrote:I'm not entirely sure what you're trying to accomplish, but when those � characters show up, it's a good sign you've got your encoding wrong somewhere.
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: PHP/MySQL storing unusual characters!
What is your page encoding?
you can send a header at the top of your PHP file like
and you can also specify it in your html head, with a meta tag
You must also user PHP's preg* functions and specify the 'u' option for unicode.
you can send a header at the top of your PHP file like
Code: Select all
header('Content-type: text/html; charset=UTF-8');Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />Re: PHP/MySQL storing unusual characters!
I'm not at home now but I'm almost sure that's what my problem is.