• 21-06-2007, 13:22:33
    #19
    Üyeliği durduruldu
    escape ile real_escape arasında ne fark var?
  • 22-06-2007, 10:24:33
    #20
    Kurumsal PLUS
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    kullanım:

    $ad = GetSQLValueString($_GET['ad'], "text");
    $id = GetSQLValueString($_GET['id'], "int");

    bütün zararlı karakterleri imha ediyoruz ve değerin başına ve sonuna ' ekliyoruz.

    $kayit = "INSERT INTO ben (ad,aciklama) values($ad, $aciklama)";

    değerler ' ' arasına alınmadan kullanılmalı. sprintf kullanılması daha sağlıklı bir kodlama olur.
  • 22-06-2007, 10:36:05
    #21
    yani bu yeterli değil midir
    $ad = htmlspecialchars(strip_tags(mysql_escape_string($_REQUEST["ad"])));
  • 22-06-2007, 10:40:00
    #22
    Kurumsal PLUS
    yetersiz demedim ama ben verdiğim fonksiyonu kullanıyorum. başım hiç ağrımadı ağrımaz da.
  • 22-06-2007, 12:32:31
    #23
    Üyeliği durduruldu
    Nereden uydurdun ki bunu?

    Tam tersine asıl PHP'nin utf8 desteği tam değil şuan.

    OnurSQL adlı üyeden alıntı: mesajı görüntüle
    addslashes, mysql_escape_string yeterli çoğu fonksiyon iso desteklemiyor, sayfayı UTF-8 olarak yapsan daha iyi olur.
  • 22-06-2007, 12:35:48
    #24
    Üyeliği durduruldu
    Sadece mysql_escape_string bu yeterli hatta sadece bunu kullanmak doğru diyeyim.

    htmlspecialchars(strip_tags(mysql_escape_string($_ REQUEST["ad"])))

    Güvenli yapacam diye bu şekilde kullanmanız yeri geldiğin yanlış bile olabilir.