Perfidus Posted August 5, 2009 Share Posted August 5, 2009 Hi there, I'm using the following query to update a DDBB and I'm getting the "too few arguments" but there's only one argument and it is given... There's something missing, but dunno what $Consulta = sprintf (" UPDATE info_table SET title = '$title, alt = '$alt', abstract = '$abstract', WHERE ref = '%s'; ", $ref ); Any hints? Link to comment https://forums.phpfreaks.com/topic/168910-solved-sprintf-too-few-arguments-but-why/ Share on other sites More sharing options...
kickstart Posted August 5, 2009 Share Posted August 5, 2009 Hi Do $title, $alt or $abstract contain any % characters? All the best Keith Link to comment https://forums.phpfreaks.com/topic/168910-solved-sprintf-too-few-arguments-but-why/#findComment-891161 Share on other sites More sharing options...
Perfidus Posted August 5, 2009 Author Share Posted August 5, 2009 mmmhhh, you mean the values? For example: $abstract = "The values have raised over 23% in the last months"; In that case, should I escape the % in the text? How can I do that? All the values are cleaned using: $abstract = mysql_real_escape_string (utf8_decode($_POST ['abstract'])); Before being stored in the database... Link to comment https://forums.phpfreaks.com/topic/168910-solved-sprintf-too-few-arguments-but-why/#findComment-891170 Share on other sites More sharing options...
Bjom Posted August 5, 2009 Share Posted August 5, 2009 a) you have % in one of the variables b) this doesn't matter if you use sprintf right c) if you have more than one variable to pass, then use more parameters d) there is a single quote missing after $title e) this is the way to go: $Consulta = sprintf ("UPDATE info_table SET title = '%s', alt = '%s', abstract = '%s', WHERE ref = '%s';", $title, $alt, $abstract, $ref); Link to comment https://forums.phpfreaks.com/topic/168910-solved-sprintf-too-few-arguments-but-why/#findComment-891174 Share on other sites More sharing options...
Perfidus Posted August 5, 2009 Author Share Posted August 5, 2009 Thanks a lot Bjom, it works like a charm... Link to comment https://forums.phpfreaks.com/topic/168910-solved-sprintf-too-few-arguments-but-why/#findComment-891195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.