From d3760862220aea24515905b66e77479f3f8bd2ef Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Thu, 18 Jan 2007 20:36:11 +0000 Subject: [PATCH] improve the example of "best practice" git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@227545 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../functions/mysql-real-escape-string.xml | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/reference/mysql/functions/mysql-real-escape-string.xml b/reference/mysql/functions/mysql-real-escape-string.xml index d587a366c2..20eb5448f9 100644 --- a/reference/mysql/functions/mysql-real-escape-string.xml +++ b/reference/mysql/functions/mysql-real-escape-string.xml @@ -1,5 +1,5 @@ - + mysql_real_escape_string @@ -121,30 +121,44 @@ SELECT * FROM users WHERE user='aidan' AND password='' OR ''='' 0) { + echo "Product inserted\n"; + } } - // Quote if not a number or a numeric string - if (!is_numeric($value)) { - $value = "'" . mysql_real_escape_string($value) . "'"; - } - return $value; +} else { + echo "Fill the form properly\n"; } - -// Connect -$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') - OR die(mysql_error()); - -// Make a safe query -$query = sprintf("SELECT * FROM users WHERE user=%s AND password=%s", - quote_smart($_POST['username']), - quote_smart($_POST['password'])); - -mysql_query($query); ?> ]]>