Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how mysql_real_escape_string work

Tags:

php

How does mysql_real_escape_string work? Does it delete mysql functions or add // between mysql function? Is it better than addslashes

like image 404
Kareem Nour Emam Avatar asked Oct 12 '22 16:10

Kareem Nour Emam


1 Answers

mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.

This function must always (with few exceptions) be used to make data safe before sending a query to MySQL.

IMO, its better to use this function than attempting to recreate, most of the time.

like image 148
KJYe.Name Avatar answered Oct 20 '22 07:10

KJYe.Name