Jump to content

[SOLVED] Warning: sprintf() [function.sprintf]: Too few arguments


phoenixx

Recommended Posts

Everything was working fine after inserting thousands of entries.  I'm actually scraping data from an external site.  I tried commenting out the one line of code I thought might be giving it an issue but keeps coming back to the error being in the following code (sql insertion).

 

//Writes the information to the database
$sql = sprintf ("INSERT INTO cl_prods(clprods_id, clprods_manufacturer, clprods_category, clprods_sku, clprods_includes, clprods_collection, clprods_group, clprods_type, clprods_style, clprods_description, clprods_keywords, clprods_details, clprods_imglarge, clprods_imgmedium, clprods_imgsmall, clprods_imgthumb, clprods_cost, clprods_pricecl, clprods_price40, clprods_price50, clprods_status, clprods_timestamp, clprods_collected) VALUES ('','$mnfctr','$cat','$skunum','$including','$collectionname','$groupname','$typename','$stylename','$description1','$keywords1','$description2','$k5','$k6','$k99','$k98','$k97','$k96','$k95','$k94','$status','$timestamp','$k')") or die(mysql_error());
mysql_query ($sql);

 

Just try

$sql = "INSERT INTO cl_prods(clprods_id, clprods_manufacturer, clprods_category, clprods_sku, clprods_includes, clprods_collection, clprods_group, clprods_type, clprods_style, clprods_description, clprods_keywords, clprods_details, clprods_imglarge, clprods_imgmedium, clprods_imgsmall, clprods_imgthumb, clprods_cost, clprods_pricecl, clprods_price40, clprods_price50, clprods_status, clprods_timestamp, clprods_collected) VALUES ('','$mnfctr','$cat','$skunum','$including','$collectionname','$groupname','$typename','$stylename','$description1','$keywords1','$description2','$k5','$k6','$k99','$k98','$k97','$k96','$k95','$k94','$status','$timestamp','$k')";

 

And one more thing, use:

or die(mysql_error());

in mysql_query() line

This function needs at least two arguments and was totally useless in your case.

 

Read more at:

http://www.php.net/manual/en/function.sprintf.php

 

No it doesn't.  You only use as many parameters as you have substitutes for.  Have you ever programmed in C and used printf()?

No it doesn't.  You only use as many parameters as you have substitutes for.  Have you ever programmed in C and used printf()?

 

Ok...It actually needs only one argument and throws no warning if there's only one.  On the other hand it's pointless to call it with one argument only.

 

 

No it doesn't.  You only use as many parameters as you have substitutes for.  Have you ever programmed in C and used printf()?

 

Ok...It actually needs only one argument and throws no warning if there's only one.  On the other hand it's pointless to call it with one argument only.

 

No, what if he wants to use it's capabilities down the line?  Less typing later. =/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.