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?

Link to comment
Share on other sites

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
Share on other sites

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