The Student Room Group

Does anyone know how to sanitise a variable?

I need to sanitise a variable but I have to think about the order in which i call the functions. I'm not really sure on how to do that?

the information is as follows:

$message = $_POST{'message'};

I then inserted below that, this:

$message = escape_tags ($message)

but then i get a message saying that "I have sanitised the $message variable correctly but the result of the sanitisation isn't being inserted into the database. Think about the order in which you call the functions."

Scroll to see replies

Reply 1
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($message);hope this works
Original post by blogbyreviews
I need to sanitise a variable but I have to think about the order in which i call the functions. I'm not really sure on how to do that?

the information is as follows:

$message = $_POST{'message'};

I then inserted below that, this:

$message = escape_tags ($message)

but then i get a message saying that "I have sanitised the $message variable correctly but the result of the sanitisation isn't being inserted into the database. Think about the order in which you call the functions."





This is hardly 'advice on everyday issues'...
$message = $_POST{'message'};
$message = escape_tags ($message)
insertIntoDatabase($message);
hope this helps
I didn’t know which section to put it in....
Original post by emmakola
in that order


No sorry I was trying to reply to Reality check but it wouldn’t let me quote message.
Original post by emmakola
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($message);hope this works


I’ll try it
Original post by emmakola
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($message);hope this works


I’ll try it
What are you trying to do here? Don't try to prevent SQL injection attacks by sanitising your data, instead you should prevent SQL injection attacks by parameterising your queries.

Have a look here: http://bobby-tables.com/php
Original post by winterscoming
What are you trying to do here? Don't try to prevent SQL injection attacks by sanitising your data, instead you should prevent SQL injection attacks by parameterising your queries.

Have a look here: http://bobby-tables.com/php


it's for the silver IDEA award. Quite a few are on coding and I can't wrap my head around it.
Original post by anonymous
$message = $_post{'message'};
$message = escape_tags ($message)
insertintodatabase($message);
hope this helps

thank you! It worked
Original post by blogbyreviews
it's for the silver IDEA award. Quite a few are on coding and I can't wrap my head around it.

I am too I've managed to get to the build a robot on maker activation it's all about loops
Original post by emmakola
I am too I've managed to get to the build a robot on maker activation it's all about loops

I'm stuck on the maker activation. IT'S SO HARD with all the coding.

what do you do with the LifeSupportCheck? I don't know what I'm supposed to do
(edited 5 years ago)
Original post by blogbyreviews
I'm stuck on the maker activation. IT'S SO HARD with all the coding.

what do you do with the LifeSupportCheck? I don't know what I'm supposed to do

Yes I do
Have you managed to run the loop? How far have you got using the pink hints
Original post by emmakola
Yes I do
Have you managed to run the loop? How far have you got using the pink hints

I'm only at the beginning of the coder's stage
Original post by blogbyreviews
I'm only at the beginning of the coder's stage

Okay function lifesSupportCheck (){

}
Original post by emmakola
Okay function lifesSupportCheck (){

}

what do I do?
Just write function in front of lifesSupportCheck
Original post by emmakola
Just write function in front of lifesSupportCheck

thanks :smile:
Original post by blogbyreviews

Remove lines 8 and 9 then run code

Latest

Trending

Trending