What should I pay attention to when the data is put into the database and retrieved and displayed on the page?
Warehouse receiving
$ STR = addslashes ($ Str );
$ SQL = \ "insert into 'tab' ('content') values (\ '$ STR \')\";
Warehouse picking
$ STR = stripslashes ($ Str );
Display time
$ STR = htmlspecialchars (nl2br ($ Str ));
<?
// -- Import the title, name, and other fields into the database (with spaces at the beginning and end)
Functiontrans_string_trim ($ Str ){
$ STR = trim ($ Str );
$ STR = eregi_replace ("'", "'' ", $ Str );
$ STR = stripslashes ($ Str );
Return $ STR;
}
//--ArticleWarehouse receiving, that is, the textarea field;
Functiontrans_string ($ Str ){
$ STR = eregi_replace ("'", "'' ", $ Str );
$ STR = stripslashes ($ Str );
Return $ STR;
}
// -- Display the data in the form from the library; convert the data in text to Trans. In textarea, the data is directly displayed without conversion.
// -- Display on the web page and filter HTMLCode; Including link addresses
Functiontrans ($ string ){
$ String = htmlspecialchars ($ string );
$ String = ereg_replace (CHR (10), "<br>", $ string );
$ String = ereg_replace (CHR (32), "", $ string );
Return $ string;
}
// -- Display on the Web page without filtering HTML code;
Functiontrans_web ($ string ){
$ String = ereg_replace (CHR (10), "<br>", $ string );
$ String = ereg_replace (CHR (32), "", $ string );
Return $ string;
}
// -- Display HTML code and leading and trailing spaces on the web page, mainly used to display User nicknames
Functiontrans_trim ($ string ){
$ String = trim ($ string );
$ String = htmlspecialchars ($ string );
$ String = ereg_replace (CHR (10), "<br>", $ string );
$ String = ereg_replace (CHR (32), "", $ string );
Return $ string;
}
// -- Display in span;
Functiontrans_span ($ string ){
$ String = ereg_replace (CHR (10), "\ n", $ string );
$ String = ereg_replace (CHR (32), "", $ string );
$ String = ereg_replace ('"'," ", $ string );
Return $ string;
}
// -- Display cookies on the web to filter HTML
Functiontrans_cookie ($ Str ){
$ STR = trans ($ Str );
$ STR = stripslashes ($ Str );
$ STR = eregi_replace ("'' "," '", $ Str );
Return $ STR;
}
?>