Two code difference



function Filtrele($Deger){
$Bir = trim($Deger);
$Iki = strip_tags($Bir);
$Uc = htmlspecialchars($Iki, ENT_QUOTES);
$Sonuc = $Uc;
return $Sonuc;

$GelenUstMenuSecimi = Filtrele($_POST[“UstMenuSecimi”]);
$GelenMenuAdi = Filtrele($_POST[“MenuAdi”]);

if(($GelenUstMenuSecimi != “”) and ($GelenMenuAdi != “”)){

$Ekle				=	$VeritabaniBaglantisi->prepare("INSERT INTO menuler (ustid, menuadi) values (?, ?)");
$Ekle->execute([$GelenUstMenuSecimi, $GelenMenuAdi]);
$EkleKontrolSayisi	=	$Ekle->rowCount();

	echo "HATA<br />";
	echo "İşlem Sırasında Beklenmeyen Bir Sorun Oluştu. Daha Sonra Tekrar Deneyiniz.<br />";
	echo "Ana Sayfaya Geri Dönmek İçin Lütfen Buraya <a href='index.php'>Tıklayınız</a>.";

echo “HATA
echo “Lütfen Boş Alan Bırakmayınız.
echo “Ana Sayfaya Geri Dönmek İçin Lütfen Buraya Tıklayınız.”;

$VeritabaniBaglantisi = null;

I don’t know what language that is, but I can spot a lot of differences, plus the problem could also be in the configuration file -


I’m assuming that is the configuration file?

The error is an sql execution error due to an incorrect value being supplied for the ustid column. Your column is apparently defined as a DATETIME data type, but you are supplying a string containing - ’ Kadın’. Either your column is not defined correctly or the value you are entering/selecting in the form is not correct.

Next, this Filtrele function is derived from w3schools. It is incorrect programming. The only thing it is doing correctly is trimming the data. The other things it is doing are wrong. Do not copy the bad code examples found on w3schools.

Sorry to have to tell you, but your instructor doesn’t know what he is doing and has no business “teaching”. Make sure to tell him htmlspecialchars is an OUTPUT function and only In an HTML context. Also tell him you VALIDATE data, NOT CHANGE IT.

His filter function is a JUNK RELIC of the 90’s.

Actually, I got the error where is, but even though the code is very similar it is not working with my code. When I exactly copy the other code (ust id column and DATETIME same), it is working. Probably, I thought I miss minor detail that is give the error.

Thank you for your help

Sponsor our Newsletter | Privacy Policy | Terms of Service