Code: Select all
Warning: sprintf(): Too few arguments in /var/www/localhost/htdocs/new_account.php on line 31here is the code:
Code: Select all
<?php
$form_values = array($_POST[uname], $_POST[pword], $_POST[fname] , $_POST[lname], $_POST[address], $_POST[city] , $_POST[state], $_POST[zip], $_POST[email]);
function quote_smart($value) {
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
$size = count($form_values);
for ($i = 1; $i <= $size; $i++) {
$format .= "%s,";
}
$alt_size = count($form_values) - 1;
for ($j = 0; $j <= $alt_size; $j++) {
$format1 .= quote_smart($form_values[$j]);
if ($j <> $alt_size) {
$format1 .= ", ";
}
}
$sql = sprintf("INSERT INTO accounts VALUES ('', $format now(), now())", $format1);
print $sql;
?>