$text1=escape_string(text1);
$text2=escape_string(text2);
insert into MINGYAN (Content1,Content2,Content3,View) VALUES ('$text1','$text2','$time',0);
function escape_string($string, $quotestyle='both') {
if( function_exists('sqlite_escape_string') ){
$string = sqlite_escape_string($string);
$string = str_replace("''","'",$string); #- no quote escaped so will work like with no sqlite_escape_string available
}
else{
$escapes = array("\x00", "\x0a", "\x0d", "\x1a", "\x09","\\");
$replace = array('\0', '\n', '\r', '\Z' , '\t', "\\\\");
}
switch(strtolower($quotestyle)){
case 'double':
case 'd':
case '"':
$escapes[] = '"';
$replace[] = '\"';
break;
case 'single':
case 's':
case "'":
$escapes[] = "'";
$replace[] = "''";
break;
case 'both':
case 'b':
case '"\'':
case '\'"':
$escapes[] = '"';
$replace[] = '\"';
$escapes[] = "'";
$replace[] = "''";
break;
}
return str_replace($escapes,$replace,$string);
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询