Okay, so i use the mysql_real_escape_string() funtion on almost everything. Both when the data is insert into the database and when I use it in a query I put it in the mysql_real_escape_string().
examples:
$query = "SELECT DISTINCT * from article WHERE (body LIKE '%$search%' OR
author LIKE '%$search%' OR title LIKE '%$search%') ORDER BY datex DESC";
$search = mysql_real_escape_string($search)
$result = mysql_query($query);
for use in a query. Like this search query
$sql = "insert into email (name,email)
values (\"$name\",\"$email\")";
$name = mysql_real_escape_string($name)
$email = mysql_real_escape_string($email)
$rs = mysql_query($sql)
or die ("Could not execute SQL query");
For inserting outside data
#create the SQL query
sql = "select * from article order by datex desc limit 3";
$author = mysql_real_escape_string($author)
$title = mysql_real_escape_string($title)
$datex = mysql_real_escape_string($datex)
$body = mysql_real_escape_string($body)
#execute the query
$rs = @mysql_query( $sql )
or die( "Could not execute SQL query" );
for when i use the data get the data out of the database
Sorry for posting such a long reply. But I'm trying to find out how it works. Is this correct? Thanks for all your comments you have all been a great help. Just please tell me if what I am doing is the right way to use mysql_real_escape_string().
P.S Are there any other big security conserns a newbie like me would need to know.
kind regards
lgefrank