|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-06-02 08:20 UTC] derick@php.net
[2004-06-02 10:58 UTC] Kmos at GodsFamily dot com
[2004-06-02 11:06 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 14:00:01 2025 UTC |
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