Jump to content

Recommended Posts

Hey,

 

I've been obsessing over this for hours now, probably have just missed something simple. But.

 

I've got a file saved in a mysql DB - which I'm then opening and echoing.

 

When it gets uploaded the euro sign '€' gets turned into this: '€'  (without quotes).

 

So I thought "great, I'll just str_replace() it". I tried this on a test script, and it worked.

 

However, when I went to add this to my main script - it didn't work. str_replace just won't replace it. strpos() won't find it either.

 

Anyone got any ideas? I just can't see what I'm doing wrong.

 

The code:

 

$script = $row['script']; //from sql
$script = str_replace(array("€","£"),array("€",'"'),$script);
echo $script;

 

Thanks

 

tree

Link to comment
https://forums.phpfreaks.com/topic/244774-mine-blown/
Share on other sites

You can str_replace all you want until you'll have to deal with the truth: encoding. Don't plan around the problem, solve it. Obviously you are reading the file in a different encoding than the encoding your database is using to store the data. Find out in what encoding the file was written and adjust your database table accordingly.

Link to comment
https://forums.phpfreaks.com/topic/244774-mine-blown/#findComment-1257313
Share on other sites

Turns out the problem was that notepad++ was in ANSI/UTF-8 instead of normal ANSI, changed it and it worked.

 

Though yes, I do need to address the problem before its made instead of creating a hacky fix.

 

UTF-8 for databases, yeah?

 

Also, how do I go about backing up a database?

 

Thanks everyone for your replies :)

Link to comment
https://forums.phpfreaks.com/topic/244774-mine-blown/#findComment-1257333
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.