phoenixx Posted August 26, 2008 Share Posted August 26, 2008 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 https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/ Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 And why do you use sprintf here? Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626118 Share on other sites More sharing options...
phoenixx Posted August 26, 2008 Author Share Posted August 26, 2008 I'm using mysql_real_escape_string in string arrays to get rid of the issues with quotes Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626120 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 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 https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626124 Share on other sites More sharing options...
phoenixx Posted August 26, 2008 Author Share Posted August 26, 2008 Working great after removing sprintf. Out of curiosity what would have made the error caused by the sprintf? Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626127 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 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 Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626128 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 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()? Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626131 Share on other sites More sharing options...
phoenixx Posted August 26, 2008 Author Share Posted August 26, 2008 Many thanks! The PHPFreaks community comes through again. Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626134 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 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 https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626148 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 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 https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626150 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 I don't think I get you... Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626152 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 I don't think I get you... If later, he wants to change the query and feels like using sprintf() to its fullest extent, he can with less change to the code. It really doesn't matter. Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626157 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 I get you now Link to comment https://forums.phpfreaks.com/topic/121423-solved-warning-sprintf-functionsprintf-too-few-arguments/#findComment-626158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.