petroz Posted April 20, 2010 Share Posted April 20, 2010 Hi Guys, I am having problem inserting a euro symbol into mysql. <? /* test sending currency symbols to server */ include 'db.php'; $symbol = $_GET['s']; $query = mysql_query("INSERT INTO `events` (`currency`) VALUES ('$symbol')"); echo "INSERT INTO `events` (`currency`) VALUES ('$symbol')"; ?> The echo prints as expected; (note.. I am actually using the symbol in the query.. This forum parses it to a utf string.) INSERT INTO `events` (`currency) VALUES ('€') But when I look at what was inserted into the database, I am getting; â I've tried passing the value to GET encoded and decoded and I get the same result each time. The strangest part is.. when I copy and paste that query into phpmyadmin... it shows up perfect. Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/ Share on other sites More sharing options...
Mchl Posted April 20, 2010 Share Posted April 20, 2010 Did you set up connection encoding to utf8 ? Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/#findComment-1045391 Share on other sites More sharing options...
petroz Posted April 20, 2010 Author Share Posted April 20, 2010 Hi Mchi, Thanks for the reply. I am not sure what you mean by connection... but the whole database is set to utf8-unicode-1, so is the script. Is there something I am missing? Thanks, Peter Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/#findComment-1045395 Share on other sites More sharing options...
Mchl Posted April 20, 2010 Share Posted April 20, 2010 I assume you're setting up a connection in db.php file. Check if there's mysql_query('SET NAMES "utf8"'); after mysql_connect(...) Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/#findComment-1045398 Share on other sites More sharing options...
petroz Posted April 20, 2010 Author Share Posted April 20, 2010 That did the job! Thanks a bunch! Is this something smart to use on all my databases connectors? Thanks Again! Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/#findComment-1045402 Share on other sites More sharing options...
Mchl Posted April 20, 2010 Share Posted April 20, 2010 If you want to use utf8, you have to make sure you use it everywhere. This includes database connection. Link to comment https://forums.phpfreaks.com/topic/199178-insert-euro-symbol/#findComment-1045410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.