0

php --- Warning: sprintf(): Too few arguments in --- on line 86 Query was empty

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE tankers_index SET sname=%s, dwt=%s, flag=%s, company=%s, black=%s, char=%s, type=%s, age=%s, type=%s, hull=%s, class=%s, cap=%s, sulp=%s, sts=%s, tmsa=%s WHERE imo=%s",
        GetSQLValueString($_POST['sname'], "text"),
        GetSQLValueString($_POST['dwt'], "text"),
                       GetSQLValueString($_POST['flag'], "text"),
                       GetSQLValueString($_POST['company'], "text"),
                       GetSQLValueString($_POST['black'], "text"),
                       GetSQLValueString($_POST['char'], "text"),
                       GetSQLValueString($_POST['age'], "text"),
                       GetSQLValueString($_POST['type'], "text"),
                       GetSQLValueString($_POST['hull'], "text"),
                       GetSQLValueString($_POST['class'], "text"),
                       GetSQLValueString($_POST['cap'], "text"),
                       GetSQLValueString($_POST['sulp'], "text"),
                       GetSQLValueString($_POST['sts'], "text"),
                       GetSQLValueString($_POST['tmsa'], "text"),
                       GetSQLValueString($_POST['imo'], "int"));

please someone can help me

Ben Taher
  • 3
  • 1
  • Could you edit your answer to include details of what you are trying to do, and the question you have about doing it? – Peter David Carter May 20 '16 at 16:32
  • The question was marked as a duplicate due to OP's comment: [*"thanks now it show other think : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'char='no', age='1234', type='t', hull='d', class='g', cap='47453', sulp='uuiuyui' at line 1"*](http://stackoverflow.com/questions/37351327/warning-sprintf-too-few-arguments-in-query-was-empty?noredirect=1#comment62219113_37351585). `char` is a MySQL reserved word and requires special attention. Wrap it in ticks `\`` or rename it to something else. – Funk Forty Niner May 20 '16 at 17:18

2 Answers2

0

In query you require 16 parameters, but for sprintf you set only 15

nospor
  • 4,190
  • 1
  • 16
  • 25
  • thanks now it show other think : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'char='no', age='1234', type='t', hull='d', class='g', cap='47453', sulp='uuiuyui' at line 1 – Ben Taher May 20 '16 at 16:42
  • CHAR is reserved word https://dev.mysql.com/doc/refman/5.5/en/keywords.html and you shouldn't call your columns with reserved words. If you do, you need to QUOTE this names - see my link – nospor May 20 '16 at 17:16
0

You have type=%s twice in your UPDATE statement.

H H
  • 2,065
  • 1
  • 24
  • 30
  • thanks now it show other think : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'char='no', age='1234', type='t', hull='d', class='g', cap='47453', sulp='uuiuyui' at line 1 – Ben Taher May 20 '16 at 16:42
  • For this I will need some more context. From the error it sounds like you are trying to save a value for a field but of the wrong type. Most likely `char='no'`. In your database structure, make sure that the values you are trying to save corresponds with the type it is expecting. E.g. `age` is type integer so 1234 is acceptable BUT if `char` is of type char then `no` is not acceptable. Also ensure that you have taken out the first `type=%s` to match the `sprint_f` parameters you are passing, and not the second one. – H H May 20 '16 at 16:46