madsongr
madsongr

Reputation: 785

Android cannot insert into database string with accents and blank space

I´m having a problem with this string: "Não Vou". It means "I don´t go". I´m trying to insert it into database with php/json file.

When I remove blank space and ~ accent it works fine.

What I have tried:

php file

include_once("db_connect.php");

$e_id = $_REQUEST["e_id"];
$yes = $_REQUEST["Vou"];
$no = $_REQUEST["Não Vou"];
$maybe = $_REQUEST["Talvez"];

$flag['code']=0;


if(isset($yes)){
    $r = mysqli_query($mysqli, "UPDATE table1 SET yes = yes + 1 WHERE id='$e_id'");
    $flag['code']=1;
}else if(isset($no)){
    $r = mysqli_query($mysqli, "UPDATE table1 SET no = no + 1 WHERE id='$e_id'");
    $flag['code']=1;
}else if(isset($maybe)){
    $r = mysqli_query($mysqli, "UPDATE table1 SET maybe = maybe + 1 WHERE id='$e_id'");
    $flag['code']=1;
}

print(json_encode($flag));
mysqli_close($mysqli);

Upvotes: 0

Views: 250

Answers (1)

Bonatti
Bonatti

Reputation: 2781

From the documentation, PHP variables should not contain special characters, or spaces, or anything out of

a letter is a-z, A-Z, and the bytes from 127 through 255 (0x7f-0xff). 

Upvotes: 1

Related Questions