Jump to content

[SOLVED] sprintf(): Too few arguments... but why??


Perfidus

Recommended Posts

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  :facewall:

$Consulta = sprintf ("
		UPDATE info_table
		SET
		title = '$title, 
		alt = '$alt', 
		abstract = '$abstract', 
		WHERE
		ref = '%s';
	", $ref
	);	

 

Any hints?

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

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

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.