sprintf error

I am getting PHP Warning: sprintf() [function.sprintf]: Too few arguments in

with this line of code but don't know why?

GetSQLValueString($_FILES['Photo']['name'], "text"));
jonofatAsked:
Who is Participating?
 
Michael701Connect With a Mentor Commented:
did you change the ; to a comma on the first line? and add the ) on the second?

it should look like this

GetSQLValueString($_FILES['Photo']['name'], "text"),
GetSQLValueString($_POST['ProjectID'], "int"));
0
 
Michael701Commented:
post a few lines around that code. include any sprintf() function before that line.

chances are it's NOT that line, but a syntax error on a previous line causing the error.

80% guess it's  missing )
0
 
jonofatAuthor Commented:
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE projects SET ClientID=%s, ClientName=%s, ProjectName=%s, Completed=%s, Cvalue=%s, thumb=%s WHERE ProjectID=%s",
                       GetSQLValueString($_POST['ClientID'], "text"),
                       GetSQLValueString($_POST['ClientName'], "text"),
                       GetSQLValueString($_POST['ProjectName'], "text"),
                       GetSQLValueString($_POST['Completed'], "text"),
                       GetSQLValueString($_POST['CValue'], "text"),
					   GetSQLValueString($_FILES['Photo']['name'], "text"));
                       GetSQLValueString($_POST['ProjectID'], "int");

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Michael701Commented:
i was wrong, so terribly wrong. humor is good, it was a misplaced )

GetSQLValueString($_FILES['Photo']['name'], "text"));

should be

GetSQLValueString($_FILES['Photo']['name'], "text"),
GetSQLValueString($_POST['ProjectID'], "int"));
0
 
jonofatAuthor Commented:
Hmm. Okay, thanks. Now I am getting

PHP Parse error: syntax error, unexpected ';' in
0
 
Ray PaseurCommented:
PHP lets you line up your code so you can find the errors visually.  Look at this - the double closing paren  on line 20 stands out like a sore thumb!

And of course, PHP is a kind, gentle, loosely typed language, so the statement on line 21 will run silently.  Don't you just hate that!
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) 
{
    $updateSQL = sprintf("UPDATE projects SET 
                        
                        ClientID=%s, 
                        ClientName=%s, 
                        ProjectName=%s, 
                        Completed=%s, 
                        Cvalue=%s, 
                        thumb=%s 
                        WHERE 
                        
                        ProjectID=%s",
                        
                        GetSQLValueString($_POST['ClientID'],       "text"),
                        GetSQLValueString($_POST['ClientName'],     "text"),
                        GetSQLValueString($_POST['ProjectName'],    "text"),
                        GetSQLValueString($_POST['Completed'],      "text"),
                        GetSQLValueString($_POST['CValue'],         "text"),
                        GetSQLValueString($_FILES['Photo']['name'], "text"));
                        GetSQLValueString($_POST['ProjectID'],       "int");

Open in new window

0
 
Ray PaseurConnect With a Mentor Commented:
Here is how I might set this up...  Putting the commas at the front seems to make it easier for me to read and follow the intent of the code.  Setting the parentheses and logic control structures on different lines is something I like to do, too.  A side benefit of this structure is that you make fewer typos when you have to go in and modify what you have written.

Best regards, and good luck with the project, ~Ray
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) 
{
    $updateSQL 
    = sprintf
    ( "UPDATE projects SET ClientID=%s
    ,   ClientName=%s
    ,   ProjectName=%s
    ,   Completed=%s
    ,   Cvalue=%s
    ,   thumb=%s 
       WHERE ProjectID=%s"
    ,   GetSQLValueString($_POST['ClientID'],       "text")
    ,   GetSQLValueString($_POST['ClientName'],     "text")
    ,   GetSQLValueString($_POST['ProjectName'],    "text")
    ,   GetSQLValueString($_POST['Completed'],      "text")
    ,   GetSQLValueString($_POST['CValue'],         "text")
    ,   GetSQLValueString($_FILES['Photo']['name'], "text")
    ,   GetSQLValueString($_POST['ProjectID'],       "int")
    )
    ;
    // ETC...

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.