#28606 [Bgs]: sprintf() function bug with classes
| From: | Kmos at GodsFamily dot com | Date: | Wed, 02 Jun 2004 08:58:15 +0000 |
| Subject: | #28606 [Bgs]: sprintf() function bug with classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-60275@lists.php.net to get a copy of this message | ||
ID: 28606
User updated by: Kmos at GodsFamily dot com
Reported By: Kmos at GodsFamily dot com
Status: Bogus
Bug Type: Compile Warning
Operating System: Windows XP SP1
PHP Version: 4.3.6
New Comment:
I don't think it's my code mistake... but ok! it's more fast to send us
to support ...
Previous Comments:
------------------------------------------------------------------------
[2004-06-02 10:57:34] Kmos at GodsFamily dot com
It's don't think it's my code mistake... but ok! it's more fast to send
us to support ...
------------------------------------------------------------------------
[2004-06-02 08:20:26] derick@php.net
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.
.
------------------------------------------------------------------------
[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