sprintf, does not like my code - only sometimes???
Posted: Thu Jun 29, 2006 4:46 pm
I've got a PHP file that processes the results of a user submitted form
I go over every field that could be passed in from the form, and build an SQL query
to insert the necessary data into a database.
Before I attempt to access any of the fields, I check if they were passed by the
user's browser with isset(). For example, here is a snippet of code I use to check
for a field, and add it to my sql string if it exists.
Seems OK to me, and it works when I test it. BUT about 1 in 100 times when a user
submits the form I will get an error in the PHP errorlog - and I don't get the data
that the user sent in due to the error
Here is the error I will sometimes get:
[Thu Jun 29 17:02:49 2006] [error] [client 69.63.192.11] PHP Warning: sprintf(): Too few arguments in /home/httpd/vhosts/mysite.com/httpdocs/quote/stage2_save.php on line 56, referer: http://www.mysite.com/quote/
So, the question then is how can I be getting an error in sprintf? I'm only accessing
a single variable, and I just confirmed one line before that the variable does exist.
Any idea what is going on here?
I go over every field that could be passed in from the form, and build an SQL query
to insert the necessary data into a database.
Before I attempt to access any of the fields, I check if they were passed by the
user's browser with isset(). For example, here is a snippet of code I use to check
for a field, and add it to my sql string if it exists.
Code: Select all
if ( isset($_REQUEST['girdle2']) ) {
$strSQL = sprintf($strSQL . ", girdle2 = '%s'",
mysql_real_escape_string($_REQUEST['girdle2'])
);
}Seems OK to me, and it works when I test it. BUT about 1 in 100 times when a user
submits the form I will get an error in the PHP errorlog - and I don't get the data
that the user sent in due to the error
Here is the error I will sometimes get:
[Thu Jun 29 17:02:49 2006] [error] [client 69.63.192.11] PHP Warning: sprintf(): Too few arguments in /home/httpd/vhosts/mysite.com/httpdocs/quote/stage2_save.php on line 56, referer: http://www.mysite.com/quote/
So, the question then is how can I be getting an error in sprintf? I'm only accessing
a single variable, and I just confirmed one line before that the variable does exist.
Any idea what is going on here?