所以我试图制作一个脚本,从我的数据库中获取所有日期,然后以 dd/mm/yy 格式向它们添加 1 天,错误故障排除工作正常,我的脚本工作正常,除此之外它无法上传到我的 SQL 数据库....
错误:“where 子句”中的未知列“排序”
这里是:
<?
$usernamedb = "goldacco"; // connect da jeg skal bruge det senere
$passworddb = "26102610asd";
$database = "goldacco_fb";
$server = "127.0.0.1";
$db_handle = mysql_connect($server, $usernamedb, $passworddb);
$db_found = mysql_select_db($database, $db_handle);
$i=0;
$f=0;
$sql_sort = "SELECT sorting FROM feedback WHERE approved='1' ORDER BY sorting ASC"; // get lowest sorting
$result_sort = mysql_query($sql_sort);
$sorting = mysql_fetch_assoc($result_sort);
$sorting[$f] = $sorting['sorting']; // 405
$sql = "SELECT date FROM feedback WHERE approved='1' ORDER BY sorting ASC"; // get date
$result_date = mysql_query($sql);
while ($row = mysql_fetch_assoc($result_date) OR die(mysql_error())) { // værdigen jeg har gemt
$olddate[$i] = $row['date'];
$new_date[$i] = substr($olddate[$i], 0, -6); // day
$new_date[$i] = str_replace("/", null, $new_date[$i]); // fjern /
$new_month[$i] = substr($olddate[$i], 2, -3); // month
$new_month[$i] = str_replace("/", null, $new_month[$i]); // fjern /
$new_year[$i] = substr($olddate[$i], 5-0); // år
$new_year[$i] = str_replace("/", null, $new_year[$i]); // fjern /
$new_date[$i] = $new_date[$i]+1;
if ($new_date[$i] == 32) { // check om det er den 31, hvis ja, sæt til 0
$new_date[$i] = 1;
$new_month[$i] = $new_month[$i] +1;
}
if ($new_month[$i] == 13) { // check om det er den 12, hvis ja, sæt til 0
$new_month[$i] = 1;
$new_year[$i] = $new_month[$i] +1;
}
$new_date[$i] = sprintf("%02s", $new_date[$i]);
$new_month[$i] = sprintf("%02s", $new_month[$i]);
$new_total[$i] = $new_date[$i] . "/" . $new_month[$i] . "/" . $new_year[$i];
$sql_into = "UPDATE feedback SET date=`$new_total` WHERE sorting=`$sorting[$f]`";
$result_date = mysql_query($sql_into);
$f++;
$i++;
}
?>