将解决方案从PHP 5.6升级到7.1时出现问题

时间:2018-04-11 09:58:59

标签: php mysql php-7

我是一名初学者,但已设法为一个客户端预订网站,该客户端在运行mysql 5.7.21和php 5.6的服务器上正常运行。

但现在我必须将网站移动到运行php 7.1的服务器

我设法在新服务器上复制数据库,我可以连接到它 - 但现在我有很多代码不能工作(使用mysql命令)。

我有以下代码,我已经替换了" mysql"与" mysqli"和一个较新的关闭db命令,但它不工作 - 代码只生成带有标题的表的顶部。 - 有人可以来救我:)?

oversigt.php:

<?php
echo "<link rel='stylesheet' type='text/css' href='css.css' />";
echo '<h2>Reserve a spot</h2>';
echo '<a href="login.php" class="text_black">Administration</a><br /><br />';



    include('dbConfig.php');



if ($dbConnected) {

$sqli = "SELECT ";
$sqli .= "SUM(Company_Bookings.Spots) as SUMSPOT, Company_Trips.ID, Company_Bookings.FK_ID, Company_Trips.MaxSpots, ";
$sqli .= "Company_Trips.Tripnr, Company_Trips.StartDate, Company_Trips.EndDate, Company_Trips.StartLocation, ";
$sqli .= "Company_Trips.DestinationDK, Company_Trips.PricePerSpot ";
$sqli .= "FROM Company_Trips ";
$sqli .= "LEFT JOIN Company_Bookings on Company_Bookings.FK_ID = Company_Trips.ID WHERE Company_Trips.EndDate >= NOW() AND Company_Trips.EndDate < DATE_ADD(NOW(), INTERVAL 2 YEAR) ";
$sqli .= "GROUP BY Company_Trips.ID, Company_Bookings.FK_ID ORDER BY Company_Trips.StartDate ASC ";

$sqli_Query = mysqli_query($sqli);

$tdOdd = 'style = "background-color: #FFFFFF;"';
$tdEven = 'style = "background-color: #ced4ee;"';

echo "<table>";
    echo "<tr>";
        echo "<th>Trip nr</th>";
        echo "<th>Days</th>";
        echo "<th>Start date</th>";
        echo "<th>End date</th>";
        echo "<th>Departure place</th>";
        echo "<th>Destination</th>";
        echo "<th>Price per day</th>";
        echo "<th>Max spots</th>";
        echo "<th>Available spots</th>";
       echo "<th>&nbsp;</th>";

    echo "</tr>";

$indx = 1;
while ($row = mysqli_fetch_array($sqli_Query, MYSQLI_ASSOC)) {
    $SUMSPOTS = $row['SUMSPOT'];
    $SpotsLeft = $row['MaxSpots'] - $SUMSPOTS;
    $Tripnr = $row['Tripnr'];
    $StartDate = $row['StartDate'];
    $EndDate = $row['EndDate'];
    $StartLocation = $row['StartLocation'];
    $DestinationDK = $row['DestinationDK'];
    $PricePerSpot = $row['PricePerSpot'];
    $MaxSpots = $row['MaxSpots'];
    $StartDate1 = strtotime($row['StartDate']);
    $EndDate1 = strtotime($row['EndDate']);
     $Datediff = $EndDate1 - $StartDate1;
     $Datediff2 = ceil($Datediff / (60 * 60 * 24));

    if (($indx % 2) == 1) {$rowClass = $tdOdd; } else { $rowClass = $tdEven; }

    echo "<tr ".$rowClass.">";

        echo "<td>".$Tripnr."</td>";
        echo "<td>".$Datediff2."</td>";
        echo "<td>".date('D d/m/Y', strtotime($StartDate))."</td>";
        echo "<td>".date('D d/m/Y', strtotime($EndDate))."</td>";
        echo "<td>".$StartLocation."</td>";
        echo "<td>".$DestinationDK."</td>";
        echo "<td>&euro; ".$PricePerSpot."</td>";
        echo "<td>".$MaxSpots."</td>";


    //  if $result = ($row = $result->fetch_assoc()){};
        echo "<td>".$SpotsLeft."</td>";

 if ($SpotsLeft < 1){
echo "<td>&nbsp;</td>";
 } else {
echo "<td><a href='createBooking.php?ID=".$row['ID']."&IDD=".$SpotsLeft."'>Book</a></td>";
 }

    echo "</tr>";

    $indx++;

 }

echo "</table>";

}
mysqli_close($sqli_Query);

?>

0 个答案:

没有答案