#28606 [Opn->Bgs]: sprintf() function bug with classes

From: Date: Wed, 02 Jun 2004 06:20:27 +0000
Subject: #28606 [Opn->Bgs]: sprintf() function bug with classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-60270@lists.php.net to get a copy of this message
ID: 28606 Updated by: derick@php.net Reported By: Kmos at GodsFamily dot com -Status: Open +Status: Bogus Bug Type: Compile Warning Operating System: Windows XP SP1 PHP Version: 4.3.6 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. . Previous Comments: ------------------------------------------------------------------------ [2004-06-02 01:02:30] Kmos at GodsFamily dot com Description: ------------ I think there is a bug with sprintf() function when I use it with more than one % to format variable output. Example: If I use two %s %s it crashes, but if I use only one %s or static values the sql query is valid and no warning errors happen. I think this is really strange, and I don't think I've mistake my php code, I code for some years.. Reproduce code: --------------- class bdsql { function query($sql="",$vars="") { $sql=sprintf($sql, $vars); $result=@mysql_query($sql); return $result; } } class kwww extends bdsql { function load_data($cat="",$scat="",$min=0,$max=10) { $result=$this->query("SELECT * FROM sites WHERE cat='%s' AND scat='%s' LIMIT %d,%d;","addslashes(htmlentities($cat)), addslashes(htmlentities($scat)), $min, $max"); } } How to use (index.php): $ret2=$kwww->load_data("computadores","internet",0,5); Expected result: ---------------- Execute the SQL query with no warning errors... Actual result: -------------- Warning: sprintf(): Too few arguments in c:\program files\apache\htdocs\kwww\kwww.php on line 38 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28606&edit=1

« previous php.bugs (#60270) next »