Does anyone know how to sanitise a variable?

Watch
This discussion is closed.
blogbyreviews
Badges: 20
Rep:
?
#1
Report Thread starter 1 year ago
#1
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."
0
emmakola
Badges: 8
Rep:
?
#2
Report 1 year ago
#2
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($mes sage);hope this works
1
Reality Check
Badges: 22
Rep:
?
#3
Report 1 year ago
#3
(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'...
1
Anonymous #1
#4
Report 1 year ago
#4
$message = $_POST{'message'};
$message = escape_tags ($message)
insertIntoDatabase($message);
hope this helps
4
blogbyreviews
Badges: 20
Rep:
?
#5
Report Thread starter 1 year ago
#5
I didn’t know which section to put it in....
0
blogbyreviews
Badges: 20
Rep:
?
#6
Report Thread starter 1 year ago
#6
(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.
2
blogbyreviews
Badges: 20
Rep:
?
#7
Report Thread starter 1 year ago
#7
(Original post by emmakola)
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($mes sage);hope this works
I’ll try it
(Original post by emmakola)
$message = $_POST{'message'};$message = escape_tags ($message)insetIntoDatabase($mes sage);hope this works
I’ll try it
0
winterscoming
Badges: 19
Rep:
?
#8
Report 1 year ago
#8
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
0
blogbyreviews
Badges: 20
Rep:
?
#9
Report Thread starter 1 year ago
#9
(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.
0
blogbyreviews
Badges: 20
Rep:
?
#10
Report Thread starter 1 year ago
#10
(Original post by anonymous)
$message = $_post{'message'};
$message = escape_tags ($message)
insertintodatabase($message);
hope this helps
thank you! It worked
0
emmakola
Badges: 8
Rep:
?
#11
Report 1 year ago
#11
(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
0
blogbyreviews
Badges: 20
Rep:
?
#12
Report Thread starter 1 year ago
#12
(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
0
emmakola
Badges: 8
Rep:
?
#13
Report 1 year ago
#13
(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
0
blogbyreviews
Badges: 20
Rep:
?
#14
Report Thread starter 1 year ago
#14
(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
0
emmakola
Badges: 8
Rep:
?
#15
Report 1 year ago
#15
(Original post by blogbyreviews)
I'm only at the beginning of the coder's stage
Okay function lifesSupportCheck (){

}
0
blogbyreviews
Badges: 20
Rep:
?
#16
Report Thread starter 1 year ago
#16
(Original post by emmakola)
Okay function lifesSupportCheck (){

}
what do I do?
Attached files
0
emmakola
Badges: 8
Rep:
?
#17
Report 1 year ago
#17
Just write function in front of lifesSupportCheck
0
blogbyreviews
Badges: 20
Rep:
?
#18
Report Thread starter 1 year ago
#18
(Original post by emmakola)
Just write function in front of lifesSupportCheck
thanks
0
blogbyreviews
Badges: 20
Rep:
?
#19
Report Thread starter 1 year ago
#19
Name:  loop soundblocks.png
Views: 502
Size:  25.1 KBemmakola
1
emmakola
Badges: 8
Rep:
?
#20
Report 1 year ago
#20
(Original post by blogbyreviews)
Name:  loop soundblocks.png
Views: 502
Size:  25.1 KBemmakola
Remove lines 8 and 9 then run code
1
X
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

If you do not get the A-level grades you want this summer, what is your likely next step?

Take autumn exams (202)
47.09%
Take exams next summer (62)
14.45%
Change uni choice through clearing (96)
22.38%
Apply to uni next year instead (44)
10.26%
I'm not applying to university (25)
5.83%

Watched Threads

View All
Latest
My Feed