我一直试图解决我的这个问题2天了,我再也想不出别的了。
第126,129和132行的未定义变量。
我一直试图使用isset或empty来稍微提高输出,但它似乎不起作用。
希望你们能帮助我:)
<body>
<head>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/smoothscroll.js"></script>
<script src="js/resetOnClick.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/styles.css" rel="stylesheet"/>
<link href="css/notifbox.css" rel="stylesheet"/>
</head>
<center><label class="control-label" style="font-size:30px">Reservation</label></center>
<center><label class="control-label" style="font-size:15px">Edit Record</label></center>
<br/>
<br/>
<?php
//$id = isset($_GET['id'])? $_GET['id'] : "";
if(isset($_POST['editreservation']))
{
include('config/config1.php');
$rsvtn = $_POST['editreservation'];
$sel = "SELECT venue.venue_type, reservation.reservation_date, reservation.reservation_time
FROM venue
INNER JOIN reservation ON reservation.Venue_idVenue = venue.idVenue where idReservation = '2';";
$query = mysqli_query($conn,$sel);
echo $sel;
if(!$editreservation)
{
printf("Error: %s\n", mysqli_error($conn));
exit();
}
while($detail = mysqli_fetch_array($query))
{
$rid = $detail['idReservation'];
$ven = $detail['venue_type'];
$res_t = $detail['reservation_date'];
$res_d = $detail['reservation_time'];
echo $ven;
?>
<form class="form-horizontal form-label-left" method="post">
<div class="form-group">
<!--BACK Button-->
<a href="Reservation Records.php" class="col-md-6 col-md-offset-3" style="font-size:20px">Back</a>
<!--BACK Button-->
</div>
<!--<input type="hidden" name="submitted" value="true"/>-->
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Venue<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="venue_type" data-content="<?php echo $ven;?>" class="form-control col-md-7 col-xs-12" name="venue_type" placeholder="Venue" required="required" type="text" value="<?php echo $ven;?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Reservation Date<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="reservation_date" data-content="<?php echo $res_d;?>" class="form-control col-md-7 col-xs-12" name="reservation_date" placeholder="Reservation Date" required="required" type="date" value="<?php echo $res_d;?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Reservation Time<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="reservation_time" data-content="<?php echo $res_t;?>" class="form-control col-md-7 col-xs-12" name="reservation_time" placeholder="Reservation Time" required="required" type="time" value="<?php echo $res_t;?>">
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<input type="hidden" name="updRsvtn" value="<?php echo $detail['idReservation'];?>">
<input type="submit" class="btn btn-primary submits" value="Save Edited" onClick="Reservation Records.php" >
</div>
</div>
<?php
}
}
?>
<?php
if(isset($_POST['updRsvtn']))
{
include('config/config1.php');
$ven = $_POST['venue_type'];
$res_d = $_POST['reservation_date'];
$res_t = $_POST['reservation_time'];
if(!mysqli_query($conn,"UPDATE reservation, venue SET venue_type = '$ven', reservation_date = '$res_d', reservation_time = '$res_t' WHERE idReservation = '$id'"))
{
echo "Not Queried: Wrong variables !";
}
else
{
header("Location: Reservation Records.php");
}
mysqli_close($conn);
}
?>
</form>
<table class = "notif pos">
<thead>
<tr>
<th><center/><b>*Old Record</b></th>
</tr>
</thead>
<tbody>
<tr>
<td><center/><?php echo $ven;?></td>
</tr>
<tr>
<td><center/><?php echo $res_d;?></td>
</tr>
<tr>
<td><center/><?php echo $res_t;?></td>
</tr>
</tbody>
</table>
</body>
答案 0 :(得分:0)
其中一个未定义的变量是,我假设$editreservation
。如果我们查看一些剪切代码,请执行以下操作:
if(isset($_POST['editreservation'])){
//$_POST['editreservation'] is set!
$rsvtn = $_POST['editreservation'];
//$rsvtn is set
if(!$editreservation){
//$editreservation has *not* been set by your code.
}
}
由于$editreservation
尚未在任何地方声明,因此您会收到未定义的变量通知。
答案 1 :(得分:-1)
变量不是&#34;设置&#34;在那一点(范围)。 如果您只想传递该错误,请尝试:
<td><center/><?php echo isset($ven) ? $ven : '' ?></td>
<td><center/><?php echo isset($res_d) ? $res_d : '' ?></td>
<td><center/><?php echo isset($res_t) ? $res_t : '' ?></td>
答案 2 :(得分:-1)
如果您想避免错误,请尝试此操作
<tr>
<td><center/><?php echo @$ven; ?></td>
</tr>
<tr>
<td><center/><?php echo @$res_d; ?></td>
</tr>
<tr>
<td><center/><?php echo @$res_t; ?></td>
</tr>
现在用您的代码替换上面的部分并检查。