We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,555 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

strip_tags and any other don't work in the function

<?php

class Database {

public function protect($data){
		
		$data = trim($data);
		$data = stripslashes($data);
		$data = strip_tags($data);
		$data = mysql_real_escape_string($data);
		return $data;
	}

}

$database = new Database();
$txt = '<strong>\\\Test///</strong>';
$txt = $database->protect($txt);
echo $txt;

And output have a <strong> tag, slashes and all with zero errors.
I try and different way to structure the function:

public function protect($data){
		
		trim($data);
		stripslashes($data);
		strip_tags($data);
		mysql_real_escape_string($data);
		return $data;
	}

But the output is the same :(
Where is my wrong?
If anyone know more good way to secure the mysql let share. Thanks for all ideas

2
Contributors
1
Reply
34 Minutes
Discussion Span
1 Year Ago
Last Updated
2
Views
gorleone
Newbie Poster
15 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

If anyone know more good way to secure the mysql let share. Thanks for all ideas

Use PDO.

As a quick debug:

public function protect($data){
		$data = trim($data);
                echo "TRIM: $data<br />";
		$data = stripslashes($data);
                echo "SSLASH: $data<br />";
		$data = strip_tags($data);
		echo "STAGS: $data<br />";
                $data = mysql_real_escape_string($data);
		echo "MRES: $data<br />";
                return $data; 
}
diafol
Keep Smiling
Moderator
10,833 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,533
Skill Endorsements: 61

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0542 seconds using 2.67MB