Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of sprintf(): Too few arguments

Tags:

php

mysql

I have an sql query like this

if (isset($_POST['no_peserta_mhs_2015'])) {
$colname_rec_mhs_2015 = $_POST['no_peserta_mhs_2015'];
}
mysql_select_db($database_connect, $connect);
$query_rec_mhs_2015 = sprintf("SELECT * FROM mhs_2015 WHERE no_peserta_mhs_2015 = %s or nama_mhs_2015 like %s ", GetSQLValueString($colname_rec_mhs_2015, "text"));

But I get this error

Warning: sprintf(): Too few arguments in C:\xampp\htdocs\gugus_2015\index.php on line 39 Query was empty

I don't know what's wrong.

like image 995
eniac05 Avatar asked Aug 12 '15 01:08

eniac05


1 Answers

You have two %s items in the string but only one parameter supplied after the string. For each '%' item in the format string it expects a matching parameter after the string to use to find in the value.

like this:

sprintf("item 1: %s, item 2: %s", "item1", "item2");

what you have is like:

sprintf("item 1: %s, item 2: %s", "item1");

so there is no entry for the item 2 string to match

like image 60
Paul Coldrey Avatar answered Oct 06 '22 17:10

Paul Coldrey