|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28606 sprintf() function bug with classes
Submitted: 2004-06-02 01:02 UTC Modified: 2004-06-02 11:06 UTC
From: Kmos at GodsFamily dot com Assigned:
Status: Not a bug Package: Compile Warning
PHP Version: 4.3.6 OS: Windows XP SP1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Kmos at GodsFamily dot com
New email:
PHP Version: OS:


 [2004-06-02 01:02 UTC] Kmos at GodsFamily dot com
I think there is a bug with sprintf() function when I use it with more than one % to format variable output.


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);
		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):

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-02 08:20 UTC]
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 as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

 [2004-06-02 10:58 UTC] Kmos at GodsFamily dot com
I don't think it's my code mistake... but ok! it's more fast to send us to support ...
 [2004-06-02 11:06 UTC]
I'm 100% sure it's a code mistake, but as this is NOT a support forum, you'll have to seek help elsewhere.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 08:03:39 2023 UTC