Php 服务器错误500;我的代码或服务器错误?

Php 服务器错误500;我的代码或服务器错误?,php,html,mysql,Php,Html,Mysql,你好,我正在做一个基本的预算系统。在过去的一周里,我一直在将文件从本地主机移动到Web服务器,并且遇到了服务器错误。通常,我可以通过稍微更改代码(声明字符集或去掉php的某些部分)来解决这些问题,但是现在我有一个页面不工作,另一个页面工作,它们有几乎相同的php,唯一的区别是变量。以下是我对不起作用的代码: <?php header('charset=utf-8'); session_start(); include_once 'checkLogin.php'; include_once

你好,我正在做一个基本的预算系统。在过去的一周里,我一直在将文件从本地主机移动到Web服务器,并且遇到了服务器错误。通常,我可以通过稍微更改代码(声明字符集或去掉php的某些部分)来解决这些问题,但是现在我有一个页面不工作,另一个页面工作,它们有几乎相同的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>

Add
ini\u集('display\u errors',1)error\u reporting()。在开发和测试代码时一定要这样做首先检查文件权限,Web服务器应该对脚本具有读取权限这只是一条开发人员控制台消息。请检查您的日志。
如果($res=$res1和$res=1)
。。。这是失败的。您正在分配而不是比较。按原样
echo'Deleted';标题(“Location:home.php”)在标题之前明确输出。
<?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>