解决方案从PHP5.6升级到7.1时出现的问题

aelbi1ox  于 2021-06-24  发布在  Mysql
关注(0)|答案(0)|浏览(269)

我是一个初学者,但已经设法为一个客户机,是运行良好的服务器与mysql 5.7.21和php5.6的预订网站。
但是现在我必须把这个站点移到一个运行php7.1的服务器上
我已经成功地在新服务器上复制了数据库,并且可以连接到它—但是现在我有很多代码无法工作(使用mysql命令)。
我有下面的代码,我用“mysqli”替换了“mysql”,还有一个更新的关闭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);

?>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题