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);

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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. =/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.