你好,我正在建立一个基本的预算系统。在过去的一周里,我一直在将我的文件从本地主机移动到网络服务器,并且遇到服务器错误500.通常我已经能够通过稍微更改我的代码来解决它们(声明字符集或删除某些位但是我现在有一个页面不能正常工作,一个页面正在工作谁有几乎相同的PHP唯一的区别是变量。这是我的代码,用于无效的代码:
<?php
header('charset=utf-8');
session_start();
include_once 'checkLogin.php';
include_once 'dbconnect.php';
error_reporting( ~E_DEPRECATED & ~E_NOTICE );
$id=$_SESSION['user'];
//this display the budget
if(isset($_GET['view'])){
$mid = $_GET['mortgageId'];//to use to get other stuff
$id = $_SESSION['id'];
$sql="SELECT * FROM Mortgage WHERE mortgageId='$mid'";
$sql1="SELECT * FROM Mortgage_Allocation WHERE mortgageId='$mid'";
$res = mysql_query($sql);
$res1 = mysql_query($sql1);
$row=mysql_fetch_array($res);
$row1=mysql_fetch_array($res1);
$Type=$row['Type'];
$Early=$row['earlyRepayment'];
$interest=$row1['Interest'];
$Ini=$row1['InitialSum'];
$month=$row1['monthlyPay'];
$length=$row1['Length'];
if(isset($_GET['delete'])){
$savingsId = $_GET['savingsId'];
$sql="DELETE FROM Mortgage WHERE mortgageId='$mid'";
$sql1="DELETE FROM Mortgage_Allocation WHERE mortgageId='$mid'";
$res=mysql_query($sql);
$res1=mysql_query($sql1);
if($res=$res1 and $res=1){
header('Location:home.php')
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel='stylesheet' typ='text/css' href='pageLayout.css'>
<style>
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
</head>
<body><!--use this to insert into table?-->
<ul>
<li><a href='home.php'>Return Home.</a></li>
<li><a href='newfile.html'>Make a new budget.</a></</li>
<li><a href='displayValues.php'>View a budget.</a></li>
<li><a href='AddonMenu.php'>A list of addons.</a></li>
<li><a href='logout.php'>Logout.</a></li>
</ul>
<table style='width:75%'>
<tr>
<th>Info</th>
<th></th>
</tr>
<tr><td>Type</td>
<td><input type='text' placeholder='<?php echo $Type ?>'/></td></tr>
<tr><td>Total Amount</td>
<td><input type='number' placeholder='<?php $TotalAmt=$Ini *pow(1 + $Interest/1,1*$Time);
$Total=round($Total, 2); echo $TotalAmt; ?>'/></td></tr>
<tr><td>Interest</td>
<td><input type='number' placeholder='<?php echo $Interest; ?>'/></td></tr>
<tr><td>Monthly Payback</td>
<td><input type='number' placeholder='<?php echo $monthlyPay; ?>'/></td></tr>
<tr><td>Length in years</td>
<td><input type='text' placeholder='<?php echo $length; ?>'/></td></tr>
<tr><td>Early Repayment Available</td>
<td><input type='text' placeholder='<?php echo $Early; ?>'/></td></tr>
<tr><td>InitialAmount</td>
<td><input type='text' placeholder='<?php echo $Ini; ?>'/></td></tr>
</table>
<form action="home.php">
<input type="submit" value="Return Home" />
</form>
</body>
</html>
我知道mysql已被弃用/不适用于较新版本,但它适用于此服务器。加密明文也没有太大问题。我在firefox控制台中遇到的错误是
'未声明HTML文档的字符编码。该 在某些浏览器配置中,文档将使用乱码文本呈现 如果文档包含US-ASCII范围之外的字符。 必须在文档中声明页面的字符编码 在传输协议中。'
由于内部服务器错误导致get请求失败。 我正在检查Get请求,信息是正确的,所以老实说我不知道出了什么问题。我想说这是服务器故障,但考虑到过去几次没有,我认为我只是遗漏了一些东西。 这是有效的类似页面:
<?php
session_start();
include_once 'checkLogin.php';
include_once 'dbconnect.php';
error_reporting( ~E_DEPRECATED & ~E_NOTICE );
$id=$_SESSION['user'];
//this display the budget
if(isset($_GET['edit'])){
$bid = $_GET['id'];//due to latest development is actually budget id
$id = $_SESSION['id'];
$sql="SELECT * FROM Budget WHERE BudgetId='$bid'";
$res = mysql_query($sql);
$row=mysql_fetch_array($res);
$Sal=$row['Sal'];//UserId and Monthyear are in [0] & [1]
$TaxReb = $row['TaxReb'];
$RetInv = $row['RetInv'];
$IntSave = $row['IntSave'];
$Pen = $row['Pen'];
$Dividends = $row['Dividends'];
$Wages = $row['Wages'];
$Loans = $row['Loans'];
$Benefits = $row['Benefits'];
$IncOther = $row['IncOther'];
$Tax = $row['Tax'];
$Groc = $row['Groc'];
$Take = $row['Take'];
$Rent = $row['Rent'];
$Elec = $row['Elec'];
$Trans = $row['Trans'];
$Mort = $row['Mort'];
$LoanPay = $row['LoanPay'];
$Goods = $row['Goods'];
$ExpOther = $row['ExpOther'];
$TotalInc = $row['TotalInc'];
$TotalExp = $row['TotalExp'];
$NetInc=$row['NetInc'];
$result=$res;
}
//this will delete
if(isset($_GET['delete'])){
$bid = $_GET['id'];
// Delete the row
$sql="DELETE FROM Budget WHERE BudgetId='$bid'";
$res = mysql_query($sql);
if ($res) {
echo 'Deleted';
header("Location: home.php");
} else {
echo "Error deleting record: " . $conn->error;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' typ='text/css' href='pageLayout.css'>
</head>
<style>
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
<body><!--use this to insert into table?-->
<ul>
<li><a href='home.php'>Return Home.</a></li>
<li><a href='newfile.html'>Make a new budget.</a></</li>
<li><a href='displayValues.php'>View a budget.</a></li>
<li><a href='AddonMenu.php'>A list of addons.</a></li>
<li><a href='logout.php'>Logout.</a></li>
<?php echo $result;?>
</ul>
<form method='post' action='updateVals.php'> <!--when finished it will send the values to be updated -->
<table style='width:75%'>
<tr>
<th>Income Name</th>
<th>Value</th>
</tr>
<tr><td>Salary</td>
<td><input type='number' name='Sal' placeholder='<?php echo $Sal ?>'/></td></tr>
<tr><td>Tax rebates</td>
<td><input type='number' name='TaxReb' placeholder='<?php echo $TaxReb ?>'/></td></tr>
<tr><td>Returns on investments</td>
<td><input type='number' name='RetInv' placeholder='<?php echo $RetInv ?>'/></td></tr>
<tr><td>Interest on savings</td>
<td><input type='number' name='IntSave' placeholder='<?php echo $IntSave?>'/></td></tr>
<tr><td>Pensions</td>
<td><input type='number' name='Pen' placeholder='<?php echo $Pen?>'/> </td></tr>
<tr><td>Dividends</td><!-- might read div as something else-->
<td><input type='number' name='Dividends' placeholder='<?php echo $Dividends?>'/></td></tr>
<tr><td>Wages</td>
<td><input type='number' name='Wages' placeholder='<?php echo $Wages ?>'/></td></tr>
<tr><td>Loans</td>
<td><input type='number' name='Loans' placeholder='<?php echo $Loans?>'/></td></tr>
<tr><td>Benefits</td>
<td><input type='number' name='Benefits' placeholder='<?php echo $Benefits ?>'/></td></tr>
<tr><td>Other</td>
<td><input type='number' name='IncOther' placeholder='<?php echo $IncOther ?>'/></td></tr>
<tr>
<th>Expense Name</th>
<th></th>
</tr>
<tr><td>Taxation</td>
<td><input type='number' name='Tax' placeholder='<?php echo $Tax ?>'/></td></tr>
<tr><td>Groceries</td>
<td><input type='number' name='Groc' placeholder='<?php echo $Groc ?>'/></td></tr>
<tr><td>Restaurants/ Take Away</td>
<td><input type='number' name='Take' placeholder='<?php echo $Take ?>'/></td></tr>
<tr><td>Rent</td>
<td><input type='number' name='Rent' placeholder='<?php echo $Rent?>'/></td></tr>
<tr><td>Electricity</td>
<td><input type='number' name='Elec' placeholder='<?php echo $Elec?>'/></td></tr>
<tr><td>Transport</td>
<td><input type='number' name='Trans' placeholder='<?php echo $Trans?>'/></td></tr>
<tr><td>Mortgage</td>
<td><input type='number' name='Mort' placeholder='<?php echo $Mort?>'/></td></tr>
<tr><td>Loan Payback</td>
<td><input type='number' name='LoanPay' placeholder='<?php echo $LoanPay?>'/></td></tr>
<tr><td>Goods and Services</td>
<td><input type='number' name='Goods' placeholder='<?php echo $Goods?>'/></td></tr>
<tr><td>Other</td>
<td><input type='number' name='ExpOther' placeholder='<?php echo $ExpOther?>'/></td></tr>
<tr><td>Total Income</td>
<td><input type='number' name='TotalInc' placeholder='<?php echo $TotalInc?>'/></td></tr>
<tr><td>Total Expenditure</td>
<td><input type='number' name='TotalExp' placeholder='<?php echo $TotalExp?>'/></td></tr>
<tr><td>Balance</td>
<td><input type='number' name='NetInc' placeholder='<?php echo $NetInc?>'/></td></tr>
<tr><td><input type='submit' value='Finish'/></td></tr>
</table>
</form>
</body>
</html>