Re: SQL Injection check (mysql)

From: Date: Mon, 22 Mar 2004 19:33:16 +0000
Subject: Re: SQL Injection check (mysql)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-181160@lists.php.net to get a copy of this message
On Sun, 21 Mar 2004 18:39:39 -0800, Chris Shiflett wrote: > > Can you explain that (and defend it)? > The reason is security. A prepared statement cannot comprimize the security of our database because all sql-statements are precompiled in the DBMS. An example using pear: $res = & DB:connect('mysql://someuser:apasswd@localhost/thedb'); $sth = $res->prepare('select * from sometable where id > ?'); $sth->execute(10); As the example demonstrates the request is hardcoded which means it cannot be manipulated by any user supplied input. A beneficial side effect is that all characters which need exscaping is automatically handled by the DBMS. E.g the string O'leary would not cause any problems. Another argument is, that it theoretically should run faster. -- Hilsen/Regards Michael Rasmussen -------------------------------------------------------------- Be careful! Is it classified?

« previous php.general (#181160) next »