MySQL possible data loss?

I write data to MySQL. The script searches the text of the word and remove the content (if found stop words). In the database the data is written (text, themselves stop the words that were found). Looking through the database I noticed the following: the record there is a bit of text, stop words (parts of which are not present in the stub). Actually a question: is jamb jamb script or MySQL? Which field type should I use (now TEXT)? Or you should encode in base? Use the MySQL library. Can come and EMOJI and other crap.
July 5th 19 at 00:02
4 answers
July 5th 19 at 00:04
the script screws up
July 5th 19 at 00:06
It's a script error that looks up words and remove them
July 5th 19 at 00:08
Insert in a mysql table for certain characters (e.g. " or ') is difficult :)
So it may mess up the creaking, maybe the insert end off. Without the code will not tell.
No, experience allows me to use addslashes in the query (although... used to do so). Here is the code (or rather part of it)
mysql_query("SET NAMES 'utf8'"); 
mysql_query("SET SESSION collation_connection = 'utf8_general_ci'");

$input = json_decode ($HTTP_RAW_POST_DATA, true); 
$text = addslashes( $input['object']['text']);
$rulelistret = check ($text , $hash , $owner);
mysql_query ("INSERT IGNORE INTO `bans` SET `in_post` = $in_post, `owner` = $owner, `post_id` = $post , `from_id` = $user , `text` = '$text', `hash` = '$hash' , `rule` = $rule , `stringattach` = '$arraystring' , `link` = '$links' , `api_response` = "");
function check ($te , $hash = "none" , $owner) {
global $comment;
$arrayret = [];
/*
if ($hash == 'd41d8cd98f00b204e9800998ecf8427e') $hash = 'none';
$time = (time())-(60*60*24*7);
$count = mysql_fetch_array (mysql_query ("SELECT COUNT(*) FROM `posts` WHERE `time`<$time AND `hash` = '$hash'"));
if ($count[0] > 4) return -1;*/
$ta = " $te ";
$r = str_replace (array ("k" , "e" , "E" , "o" , "O" , "p" , "P" , "H" , "T" , "y" , "a" , "a" , "K" , "x" , "X" , "c" , "C" , "B" , "M" , "!" , "*" , "#" , "%" , "&" , "?" , "_" , "-") , array ("K" , "e" , "e" , "o" , "o" , "R" , "R" , "n" , "t" , "u" , "a" , "a" , "K" , "x" , "x" , "C" , "C" , "b" , "m" ) , $te);
if ($comment)
 $s = mysql_query ("SELECT * FROM `rules` WHERE `comments_e` = 1 AND `disable` = 0 AND (`groups` = $owner OR `groups` = 0) ORDER BY `rules`.`id` ASC ");
else
 $s = mysql_query ("SELECT * FROM `rules` WHERE `posts_e` = 1 AND `disable` = 0 AND (`groups` = $owner OR `groups` = 0) ORDER BY `rules`.`id` ASC ");

for ($q = mysql_fetch_array ($s) ; $q!=false ; $q = mysql_fetch_array ($s)) {
$arr[] = $q;
}


foreach ($arr as $cur) {
 $t = $ta;
 if ($cur[0] != 118) {
 $t = $r;
}
 $test=json_decode ($cur[1] , true);
 $counta = count ($test);
 unset ($xx);
 foreach ($test as $ss) {
 if (cw($ss , $t)) $xx++;
 if ($xx==$counta && $counta!=0) {$arrayret[] = $cur[0];}
}
}
 return $arrayret;
}

function cw ($worlds , $text) {
 if ( gettype($worlds)=="array") {
 foreach ($worlds as $world) {
 $lw = $world;
 $lt = mb_strtolower ($text , "UTF-8");
 $c = preg_match("/$lw/uis" , "$lt");
 if ($c==1) { return true;}
 } 
 return false;
 } else {
 $lw =$worlds;
 $lt = mb_strtolower ($text , "UTF-8");
 $c = preg_match("/$lw/uis" , "$lt" );
 if ($c==1) { return true;} else return false;
}
}
- Kelsi43 commented on July 5th 19 at 00:11
Yes I know it's not very good code. - Kelsi43 commented on July 5th 19 at 00:14
Would need a sample that does not stick. Original what goes into the base. - robbie.Wuns commented on July 5th 19 at 00:17
July 5th 19 at 00:10
Catch specific cases (logisuite the queries to the database)
I had a similar problem when the text was emoji, and all sorts of characters," ` %

Find more questions by tags MySQLPHP