Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Filtracja PHP zapisywanego do Mysql "mysql_escape_string"
Spyder
post
Post #1





Grupa: Zarejestrowani
Postów: 269
Pomógł: 7
Dołączył: 12.10.2006
Skąd: Newcastle Upon Tyne

Ostrzeżenie: (0%)
-----


Witam

Kiedy wysylam do bazy kod php ponizej wpisuje mi do bazy ale tylko poczatek. Tu jak filtruje dane:
  1. $CommentContent = htmlspecialchars(mysql_escape_string(trim($_POST['CommentContent'])));


Dokladnie dodaje mi tylko to:

  1. <?php
  2.  
  3. // Strip magic quotes from request data.
  4. if (function_exists('get_magic_quotes_gpc')
i wywala sie na &&

Nie mam limitu znakow. Dzieki


WYSTLANY KOD DO BAZY PONIZEJ
  1. <?php
  2.  
  3. // Strip magic quotes from request data.
  4. if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
  5. // Create lamba style unescaping function (for portability)
  6. $quotes_sybase = strtolower(ini_get('magic_quotes_sybase'));
  7. $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)';
  8. $stripslashes_deep = create_function('&$value, $fn', '
  9. if (is_string($value)) {
  10. $value = ' . $unescape_function . ';
  11. } else if (is_array($value)) {
  12. foreach ($value as &$v) $fn($v, $fn);
  13. }
  14. ');
  15.  
  16. // Unescape data
  17. $stripslashes_deep($_POST, $stripslashes_deep);
  18. $stripslashes_deep($_GET, $stripslashes_deep);
  19. $stripslashes_deep($_COOKIE, $stripslashes_deep);
  20. $stripslashes_deep($_REQUEST, $stripslashes_deep);
  21. }
  22.  
  23. ?>


Ten post edytował Spyder 15.08.2010, 16:19:41
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
thek
post
Post #2





Grupa: Moderatorzy
Postów: 4 362
Pomógł: 714
Dołączył: 12.02.2009
Skąd: Jak się położę tak leżę :D




A zamień sobie kolejność htmlspeciachars (lub htmlentities) i mysql_real_escape_string.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 08:27