From:             Kmos at GodsFamily dot com
Operating system: Windows XP SP1
PHP version:      4.3.6
PHP Bug Type:     Compile Warning
Bug description:  sprintf() function bug with classes

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);
                [EMAIL PROTECTED]($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 bug report at http://bugs.php.net/?id=28606&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28606&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28606&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28606&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28606&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28606&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28606&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28606&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28606&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28606&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28606&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28606&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28606&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28606&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28606&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28606&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28606&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28606&r=float

Reply via email to