note 70445 rejected from function.mysql-real-escape-string by betz

From: Date: Tue, 17 Oct 2006 08:02:15 +0000
Subject: note 70445 rejected from function.mysql-real-escape-string by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-118599@lists.php.net to get a copy of this message
Note Submitter: chris at rubberducktech dot com ---- On my machine, doing this (right from the manual) if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number or a numeric string if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } allows for a javascript injection <script language="Javascript"> <!-- alert ("This is a Javascript Alert") //--> </script> However if I change it to if (!get_magic_quotes_gpc()) { $value = addslashes($value); } // Quote if not a number or a numeric string if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } everything works great and the double quotes are escaped only once very nicely which seems to go against what the manual says.

« previous php.notes (#118599) next »