PHP &

0 Cevap php

Tamam ben bir kullanıcı yaklaşan örnekteki gibi bir şey girdiğinde strip_tags, bir kullanıcı bir yazı etiketleri ne zaman html kurtulmak ama olsun kullanıyorum.

Ben her şey gayet istemiyorum veritabanına girilen beş boş değerleri olsun. I bu nasıl durdurabilirim?

,,,,,,,, ,, ,,,,a,d, <html> , ruby-on-rails , ad, <html>

Ben veritabanına girilen aşağıdaki NOTE the commas are not entered into the database olsun.

, , , a, d, , ruby-on-rails, ad, 

İşte benim kodudur.

$tags = preg_split('/,/', strip_tags($_POST['tag']), -1, PREG_SPLIT_NO_EMPTY);
$tags = array_map('trim', $tags);
$tags = str_replace(' ', '-', $tags);

ONLY the following should be entered into the database.

a,d,ruby-on-rails,ad 

İşte benim ekin hızlı bir örnektir.

 for ($x = 0; $x < count($tags); $x++){
    $query1 = "INSERT INTO tags (tag) VALUES ('" . mysqli_real_escape_string($mysqli, strtolower($tags[$x])) . "')";
}

0 Cevap