Page 1 of 1

Should be trivial -- WTH?

Posted: Sun Oct 12, 2008 3:05 pm
by alex.barylski
EDIT | I think I may have just spotted the problem...missing closing ) affected another query of mine so maybe thats it.
I have this line of code:

Code: Select all

$sql = sprintf("INSERT INTO %sproofs VALUES(0, $puid, $time, '$proof', '$rawdata'", DB_PREFIX);
Simple right? Spot the error, cause I don't... :banghead:

Code: Select all

Warning: sprintf() [function.sprintf]: Too few arguments in /var/www/devine/core/functions.php on line 127
What am I missing, I frequently use this technique to construct SQL statements and I have never encountered this problem before...I'm quite irritated by this and I hope in my frustration I am missing something simple.

Re: Should be trivial -- WTH?

Posted: Mon Oct 13, 2008 2:08 am
by Ziq
This is a very simple error :)

If you try to add into database some values including '%s' you are getting this error. For example:

Code: Select all

 
define('DB_PREFIX', 'a_');
$proof = "it's your error %s";
$sql = sprintf("INSERT INTO %sproofs VALUES(0, $puid, $time, '$proof', '$rawdata'", DB_PREFIX);
echo $sql;