Home > PHP > PHP – utf8

PHP – utf8

http://www.my-debugbar.com/wiki/IETester/HomePage

hmmm, utf8 ?

<?php
#find the company name
$result = sql(“select naam FROM companies where naam like ‘$_get%'”);
while ($row = mysql_fetch_array($result)){
$val = $val . $spa .  $row[0];    $spa = “\n”;
}
# trying and trying, didnt worked!! ok forget it…
//if ( stristr($_SERVER[“HTTP_ACCEPT”],”application/xhtml+xml”) ) {
//header(“Content-type: application/xhtml+xml;charset=utf-8”);
//header(“Content-type: text/plain;charset=utf-8”); } else {   header(“Content-type: text/plain;charset=utf-8”); }

# it worked!!
echo utf8_encode($val);
?>

so, crack 1:

$.ajax ({

success: function(msg) {

console.log ( msg ); // works…..

}});

or, crack 2:

http://phpjs.org/functions/index

$.ajax ({    success: function(msg) {

msg =     utf8_encode ( msg);   console.log ( msg ); // works…..

}});

UTF8/ Single ‘ Quote/ Double ” Quotes

=============================================

text =

I am fr bad  boy: adaptée à problème honnête qu’un, “mon profil”
I am en good boy: abcdefghijklmnopqrstuvwxyz

1. from javascript submit ajax to php

2. PHP receives?

$_POST[‘vraagFR’] = addslashes($_POST[‘vraagFR’]); // insert into database, find ‘ and replace to \’

3. When read back use utf8_decode ( $that mysql value ) to browser

Advertisements
Categories: PHP Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: