0

i have what should be a simple question. (Table = Leads, Field = message)

the SQL command that I want to use is: UPDATE Leads SET message = REPLACE(message, 'Â', '')

when I execute this in the SQL command window of phpMyAdmin, it works like a charm.

however, when I include it in a simple php file, it DOESN'T work.

here's the php code:

$sql2 = "UPDATE Leads SET message = REPLACE(message, 'Â', '')";
if (mysqli_query($conn, $sql2))
{
    echo "SUCCESS";
}
else
{
    echo "FAILURE";
}

it displays "SUCCESS" - but the character doesn't get replaced.

any suggestions?

SATXbassplayer
  • 101
  • 1
  • 7
  • can you show data ? – krishn Patel May 26 '17 at 03:22
  • 1
    That might be an encoding problem. You should try it with an ascii literal to check. – pvg May 26 '17 at 04:02
  • @pvg - you are correct - when i replaced 'XXX' in the php file, the SQL query worked! unfortunately, i need to remove 'Â' - any thoughts or suggestions? – SATXbassplayer May 26 '17 at 15:50
  • @pvg - i added mysqli_query($conn, "SET NAMES 'utf8'"); right after connecting, and BINGO - worked fine. THANKS FOR THE HELP! – SATXbassplayer May 26 '17 at 16:02
  • 1
    Np, if you're going to support utf8 in your db/app, you might want to read this https://stackoverflow.com/questions/202205/how-to-make-mysql-handle-utf-8-properly - especially the first answer and the comments carefully. One thing that can mess up your day is that when mysql says utf8 they don't actually mean utf8. – pvg May 26 '17 at 16:25

0 Answers0