Forum Moderators: coopster
sprintf('INSERT INTO `users` (`firstName`, `email`, `password`, `zipCode`, `gender`, `maritalStatus`, `children`, `annualIncome`, `emailOffers`, `categories`, `dateOfBirth`, `authorization`) VALUES ("%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s")', mysql_real_escape_string("username"), mysql_real_escape_string("dummy@example.com"), mysql_real_escape_string("password"), mysql_real_escape_string("11111"), mysql_real_escape_string("M"), mysql_real_escape_string(""), mysql_real_escape_string("0"), mysql_real_escape_string(""), mysql_real_escape_string("1"), mysql_real_escape_string("1,3,10,17"), mysql_real_escape_string("1989-03-4"), mysql_real_escape_string("NALXq5aRm7J7")); Warning: sprintf() [function.sprintf]: Too few arguments in /Applications/xampp/xamppfiles/htdocs/slh/core/functions.php on line 918
Query was empty foreach($array as $key => $val){
if(is_array($val)){
foreach($val as $key2 => $val2){
$val2 = cleanData($val2);
$array[$key].$val[$key2] = $val2;
}
} else {
$val = cleanData($val);
$array[$key] = $val;
}
}
$dob = $array['date_of_birth_year'].'-'.$array['date_of_birth_month'].'-'.$array['date_of_birth_day'];
foreach ($array as $key => $val){
if($key != 'date_of_birth_year' && $key != 'date_of_birth_month' && $key != 'date_of_birth_day' && $key != 'recaptcha_challenge_field' && $key != 'recaptcha_response_field'){
$col .= '`';
$col .= $key;
$col .= '`, ';
}
}
$col .= '`dateOfBirth`, `authorization`';
foreach ($array as $key => $val){
if($key != 'date_of_birth_year' && $key != 'date_of_birth_month' && $key != 'date_of_birth_day' && $key != 'recaptcha_challenge_field' && $key != 'recaptcha_response_field'){
$items .= '"';
$items .= '%s';
$items .= '",';
}
}
$items .= '"%s","%s"';
foreach ($array as $key => $val){
if(is_array($val)){
$entries .= 'mysql_real_escape_string("';
foreach($val as $key2 => $val2){
$entries .= $val2;
$entries .= ',';
}
$entries = rtrim($entries, ',');
$entries .= '"';
} elseif($key != 'date_of_birth_year' && $key != 'date_of_birth_month' && $key != 'date_of_birth_day' && $key != 'recaptcha_challenge_field' && $key != 'recaptcha_response_field'){
$entries .= 'mysql_real_escape_string("';
$entries .= $array[$key];
$entries .= '"), ';
}
}
$code = activationCode(12);
$entries .= '), mysql_real_escape_string("'.$dob.'"), mysql_real_escape_string("'.$code.'")';
}
$query = "INSERT INTO `users` (".$col.") VALUES (".$items.")";
$sql = sprintf($query, $entries);
$inserted = mysql_query($sql) or die(print($sql).' <br /> '. mysql_error());
$query = "INSERT INTO `users` (".$col.") VALUES (".$items.")";
$sql = sprintf($query, $entries);
%s...
$sql = sprintf($query, $entries); INSERT INTO `users` (`firstName`, `email`, `password`, `zipCode`, `gender`, `maritalStatus`, `children`, `annualIncome`, `emailOffers`, `categories`, `dateOfBirth`, `authorization`) VALUES ("%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s") count as the formatting? Is it the fact that I'm trying to pass a variable into the sprintf statement? I even tried making a string of the sprintf statement. So, the the statement is fully compiled as a string. Then I tried to pass it to eval in order to make it register as a sprintf function, but that didn't work either. I ended up with the query is empty again.