我遇到此错误 警告:session_start():标头已发送
时无法启动会话这是第84行的代码,我在此出错。
<?php
session_start();
function Delete_tables(){
$conn = mysqli_connect($_SESSION['hostname'], $_SESSION['dbusername'], $_SESSION['dbpassword'], $_SESSION['dbname']);
$result = mysqli_query($conn, "show tables");
while($table = mysqli_fetch_array($result, MYSQLI_BOTH)) {
//echo "<tr><td>".$table[0] . "</td></tr>";
$drop_tab = mysqli_query($conn , 'DROP TABLE IF EXISTS `'.$_SESSION['dbname'].'`.`'.$table[0].'`');
}
if($drop_tab) {
//return "<p class='drop-noti'>Tables droped successfully</p><script>jQuery(document).ready(function(){jQuery('.drop-noti').fadeOut(5000);window.location = location.href; });</script>";
return "<p class='drop-noti'>Tables droped successfully</p><script>jQuery(document).ready(function(){setTimeout(function(){jQuery('.drop-noti').fadeOut(function() {window.location = window.location.href; });}, 5000);});</script>";
}
else {
return mysqli_error($conn);
}
}
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'drop' : $result = Delete_tables();break;
case 'test' : test();break;
}
echo $result; die;
}
?>