ÔÎÄ£ºhttp://www.phpddt.com/php/228.html
£¨1£©mysql_real_escape_string -- תÒå SQL Óï¾äÖÐʹÓõÄ×Ö·û´®ÖеÄÌØÊâ×Ö·û£¬²¢¿¼Âǵ½Á¬½ÓµÄµ±Ç°×Ö·û¼¯
ʹÓ÷½·¨ÈçÏ£º
$sql = "select count(*) as ctr from users where username ='".mysql_real_escape_string($username)."' and password='". mysql_real_escape_string($pw)."' limit 1";
ʹÓà mysql_real_escape_string()
×÷ΪÓû§ÊäÈëµÄ°ü×°Æ÷£¬¾Í¿ÉÒÔ±ÜÃâÓû§ÊäÈëÖеÄÈκζñÒâ SQL ×¢Èë¡£
£¨2£© ´ò¿ªmagic_quotes_gpcÀ´·ÀÖ¹SQL×¢Èë
php.iniÖÐÓÐÒ»¸öÉèÖãºmagic_quotes_gpc = Off
¡¡¡¡Õâ¸öĬÈÏÊǹرյģ¬Èç¹ûËü´ò¿ªºó½«×Ô¶¯°ÑÓû§Ìá½»¶ÔsqlµÄ²éѯ½øÐÐת»»£¬
¡¡¡¡±ÈÈç°Ñ ' תΪ \'µÈ£¬¶ÔÓÚ·ÀÖ¹sql×¢ÉäÓÐÖØ´ó×÷Óá£
Èç¹ûmagic_quotes_gpc=Off£¬ÔòʹÓÃaddslashes()º¯Êý
£¨3£©×Ô¶¨Ò庯Êý
function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str); } function verify_id($id=null) { if(!$id) { exit('ûÓÐÌá½»²ÎÊý£¡'); } elseif(inject_check($id)) { exit('Ìá½»µÄ²ÎÊý·Ç·¨£¡'); } elseif(!is_numeric($id)) { exit('Ìá½»µÄ²ÎÊý·Ç·¨£¡'); } $id = intval($id); return $id; } function str_check( $str ) { if(!get_magic_quotes_gpc()) { $str = addslashes($str); // ½øÐйýÂË } $str = str_replace("_", "\_", $str); $str = str_replace("%", "\%", $str); return $str; } function post_check($post) { if(!get_magic_quotes_gpc()) { $post = addslashes($post); } $post = str_replace("_", "\_", $post); $post = str_replace("%", "\%", $post); $post = nl2br($post); $post = htmlspecialchars($post); return $post; }
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ