Ik had volgend PHP script lopen bij een provider voor het ophalen van mijn data uit een sql database en dat werkte perfect .
Na overstap na een andere provider werkt dit script niet meer .
Provider heeft PHP8.4 versie .
Mijn script :
<?php
// Database configuration
$Hostname = 'xxxxxxxx'; // Je hostnaam
$User = 'xxxxxxxx'; // Je gebruikersnaam
//$usertable = "xxxxxxxx"; // Database table name that gets created by setup
$Password ='xxxxxx'; // Je wachtwoord
$Database = 'xxxxxxxxx'; // Je databasenaam
// Create database connection
mysqli_connect($Hostname, $User, $Password, $Database);
// Check connection
if(mysqli_connect_error())
{
echo "Connection establishing failed!";
}
else
{
echo "Connection established successfully.";
}
// Tot op dit punt alles ok
// SQL query to select data from database
$sql = " SELECT * FROM OnlineLogBook ORDER BY date DESC limit 10 ";
//$result = $mysqli->query($conn ,$query ); // aanpassing echter dit geeft dezelfde fout melding
$result = $mysqli->query($sql); // dit is line 27 met de fout
$mysqli->close();
?>
// fout melding : Got error 'PHP message: PHP Warning: Undefined variable $mysqli in /data/sites/web/on7ykeu/www/loginon7yk.php on line 27; PHP message: PHP Fatal error: Uncaught Error: Call to a member function query() on null in /data/sites/web/on7ykeu/www/loginon7yk.php:27\nStack trace:\n#0 {main}\n thrown in /data/sites/web/on7ykeu/www/loginon7yk.php on line 27'
Iemand kan mij hier een hint geven ??????
// Html zonder PHP script komt perfect op de pagina
<!-- HTML code to display data in tabular format -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Logbook</title>
<!-- CSS FOR STYLING THE PAGE -->
<style>
table {
margin: 0 auto;
font-size: small;
border: 1px solid black;
}
h1 {
font-size : 18px;
text-align : center;
color : #fff;
}
h2{
font-size : 16px;
text-align : center;
color : #000066;
}
th {
font-weight: bold;
color: #0f0;
border: 1px solid black;
padding: 10px;
text-align: center;
font-size : 16px;
}
td{
background-color: #ccc;
font-weight: bold;
color: #000;
padding: 5px;
text-align: center;
font-size : 14px
}
</style>
</head>
<body>
<section>
<h1>Multi Call Logbook . Last 10 Qso's for all my calls . </h1>
<h1>Included expedition and special call sign .</h1>
<!-- TABLE CONSTRUCTION -->
<table>
<tr>
<th>Date</th>
<th>Time</th>
<th>Call Sign</th>
<th>Band</th>
<th>Freq.</th>
<th>Mode</th>
<th>Rst Send</th>
<th>My Call sign</th>
</tr>
<!-- PHP CODE TO FETCH DATA FROM ROWS -->
<?php
// LOOP TILL END OF DATA
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>
<!-- FETCHING DATA FROM EACH
ROW OF EVERY COLUMN -->
<td><?php echo $rows['Date'];?></td>
<td><?php echo $rows['Time'];?></td>
<td><?php echo $rows['CallSign'];?></td>
<td><?php echo $rows['Band'];?></td>
<td><?php echo $rows['Frequency'];?></td>
<td><?php echo $rows['Mode'];?></td>
<td><?php echo $rows['RSTS'];?></td>
<td><?php echo $rows['MyCallsign'];?></td>
</tr>
$conn->close();
<?php
}
?>
</table>
</section>
</body>
</html>