[wp-trac] [WordPress Trac] #13195: mysql_real_escape_string() gives warning when non-string passed in

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 30 21:12:03 UTC 2010


#13195: mysql_real_escape_string() gives warning when non-string passed in
--------------------------+-------------------------------------------------
 Reporter:  MrWiblog      |       Owner:                                    
     Type:  defect (bug)  |      Status:  new                               
 Priority:  normal        |   Milestone:  3.0                               
Component:  Validation    |     Version:  3.0                               
 Severity:  normal        |    Keywords:  wp-db.php mysql_real_escape_string
--------------------------+-------------------------------------------------
 I got an error from my Demo Data plugin in WP3.0 beta 1:

 Warning: mysql_real_escape_string() expects parameter 1 to be string,
 array given in ...\wp-includes\wp-db.php on line 772

 I think an integer was being passed to the function, so casting the input
 as a string sorted it out:

 return mysql_real_escape_string( $string, $this->dbh );

 became

 return mysql_real_escape_string( (string)$string, $this->dbh );

 Patch attached.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13195>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list