PHP foutje die maar niet te herleiden is

Angela69

Gebruiker
Lid geworden
9 mrt 2017
Berichten
447
Besturingssysteem
Windows
Office versie
365
Deze foutmelding krijg ik als een php bestand vernieuw, het woord "voorzichtig" is nergens in het bestand te vinden. Iemand enig idee wat het probleem kan zijn?

1778939708508.webp
 
Wat staat er dan wél op en rond lijn 88?
Ik vermoed dat die string 'voorzichtig' ergens uit de database komt, en geinjecteerd wordt in die variabele op lijn 88.
 
Het hele woord 'voorzichtig' komt niet in het bestand voor, dus als het in de database staat, hoe halen we hem er dan uit?
 
Door mijn vorige bericht even opnieuw te lezen.....

Tot nu toe is het in een glazen bol kijken! 🔮
 
regel 5 hier is regel 8 in de foutmelding

1778962070736.webp
 
Heel fijn, maar de foutmelding heeft het toch echt over regel 88. Heb je de error in het algemeen al gegoogled?
 
sorry, ik word hier ook simple van, bij het sreepje is regel 88 1778962302953.webp
 
Kan je de code eens niet screenshotten, maar netjes hier delen in een code blok (</> knop).

Anders is het wel heel lastig debuggen.
 
wil je de hele code hebben van dit item?
 
ik doe het in delen, want het bestand vind Helpmij te groot
 
Hoeveel regels is het bestand eigenlijk?
Kan je het niet even isoleren? En een klein behapbaar stuk geven. Ik heb ook weer geen zin om duizend regels aan code te debuggen.

En misschien is het ook wel handig om te vertellen wanneer het probleem ontstond. Het gebeurt niet zomaar. Misschien kan je zelfs een back-up terugzetten.
 
<?php
/**
* BESTAND: inc-statistiek.php
* VERSIE: 122.0 (PERSONAL SPEELDAGEN SYNC)
* INFO: Synchroniseert de persoonlijke speeldagen van het ingelogde lid.
* BLIJFT VERDER VOLLEDIG AF VAN HET ONDERSTE GEDEELTE EN DE DATA.
* Regels zijn extra kort en smal tegen scrollen.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

function vbv_render_oorspronkelijke_statistieken_v89() {
$uid = get_current_user_id();
if (!$uid) return "Log in.";
$user = wp_get_current_user();
$mp = (int)get_user_meta($uid, '_meesterpnt', true);
$rating = get_user_meta($uid, '_nbb_rating', true) ?: '-';
$lid_datum = get_user_meta($uid, '_toetreding', true) ?: '';

// 1. Haal de live Excel database op om uw eigen speeldagen te bepalen

$nbb_master = get_option('vbv_zittingen_master_db', array());
if (!is_array($nbb_master)) { $nbb_master = array(); }




$mijn_lidnummer = $user->user_login;
$speeldagen_lijst = [];

if (!empty($nbb_master) && isset($nbb_master[$mijn_lidnummer])) {
$ik = $nbb_master[$mijn_lidnummer];
$v_ma = strtolower(trim($ik['Ma Avo'] ?? $ik['Ma avo'] ?? ''));
$v_wo = strtolower(trim($ik['Wo Mid'] ?? $ik['Wo mid'] ?? ''));
$v_do = strtolower(trim($ik['Do Avo'] ?? $ik['Do avo'] ?? ''));

if (!empty($v_ma) && !in_array($v_ma, ['n', 'nee', '0'])) { $speeldagen_lijst[] = 'MA'; }
if (!empty($v_wo) && !in_array($v_wo, ['n', 'nee', '0'])) { $speeldagen_lijst[] = 'WO'; }
if (!empty($v_do) && !in_array($v_do, ['n', 'nee', '0'])) { $speeldagen_lijst[] = 'DO'; }
}

// 🟢 DE DYNAMISCHE FIX: Als de lijst leeg is valt hij terug op MA
$speeldagen = !empty($speeldagen_lijst) ? implode(', ', $speeldagen_lijst) : 'MA';

$mijlpalen = [
['n'=>'Clubmeester','g'=>500], ['n'=>'Districtsmeester','g'=>2000],
['n'=>'Regionaalmeester','g'=>5000], ['n'=>'Kand. Bondsmeester','g'=>10000],
['n'=>'Bondsmeester','g'=>15000], ['n'=>'Nationaal Meester','g'=>30000],
['n'=>'Nat. Meester *','g'=>60000], ['n'=>'Nat. Meester **','g'=>100000],
['n'=>'Nat. Meester ***','g'=>150000]
];
$voluest = "Titel"; $nodig = 0;
foreach($mijlpalen as $m) {
if($mp < $m['g']) { $voluest = $m['n']; $nodig = $m['g'] - $mp; break; }
}
$eigen_tempo = 45;
$prognose = date_i18n('F Y', strtotime("+".ceil($nodig / $eigen_tempo)." months"));

$stats = [
'MA' => ['tot'=>0,'m'=>0,'v'=>0,'veen'=>0,'mp'=>0,'r'=>0,'l_tot'=>0,'l_tel'=>0,'j_tot'=>0,'j_tel'=>0],
'WO' => ['tot'=>0,'m'=>0,'v'=>0,'veen'=>0,'mp'=>0,'r'=>0,'l_tot'=>0,'l_tel'=>0,'j_tot'=>0,'j_tel'=>0],
'DO' => ['tot'=>0,'m'=>0,'v'=>0,'veen'=>0,'mp'=>0,'r'=>0,'l_tot'=>0,'l_tel'=>0,'j_tot'=>0,'j_tel'=>0],
'TOT'=> ['tot'=>0,'m'=>0,'v'=>0,'veen'=>0,'mp'=>0,'r'=>0,'l_tot'=>0,'l_tel'=>0,'j_tot'=>0,'j_tel'=>0]
];

$titels_teller = [
'zonder'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0], 'club'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0],
'dist'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0], 'regio'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0],
'kand'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0], 'bonds'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0],
'nat'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0], 'nat1'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0],
'nat2'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0], 'nat3'=>['MA'=>0,'WO'=>0,'DO'=>0,'TOT'=>0]
];

$excel_vandaag = 46158;

if (!empty($nbb_master)) {
foreach ($nbb_master as $id => $lid) {
$gender = strtolower(trim($lid['Geslacht'] ?? ''));
$is_man = ($gender === 'm' || $gender === 'man');

$pc_raw = (string)($lid['Postcode'] ?? '');
$pc_num = (int)preg_replace('/[^0-9]/', '', $pc_raw);
$is_veen = ($pc_num >= 3901 && $pc_num <= 3911);

$l_mp = (int)($lid['Meesterpunten'] ?? 0);
$l_r = (int)($lid['NBB-rating'] ?? 0);

$l_leeftijd = 0; $has_geb = false;
$g_raw = $lid['Geboortedatum'] ?? '';
if (is_numeric($g_raw) && (int)$g_raw > 1000) {
$l_leeftijd = ($excel_vandaag - (int)$g_raw) / 365.25;
if ($l_leeftijd > 10) $has_geb = true;
}

$l_jaren = 0; $has_jaren = false;
$t_raw = $lid['Datum toetreding'] ?? '';
if (is_numeric($t_raw) && (int)$t_raw > 1000) {
$l_jaren = ($excel_vandaag - (int)$t_raw) / 365.25;
if ($l_jaren >= 0) $has_jaren = true;
}

$v_ma = strtolower(trim($lid['Ma Avo'] ?? $lid['Ma avo'] ?? ''));
$v_wo = strtolower(trim($lid['Wo Mid'] ?? $lid['Wo mid'] ?? ''));
$v_do = strtolower(trim($lid['Do Avo'] ?? $lid['Do avo'] ?? ''));

$speelt_ma = (!empty($v_ma) && !in_array($v_ma, ['n', 'nee', '0']));
$speelt_wo = (!empty($v_wo) && !in_array($v_wo, ['n', 'nee', '0']));
$speelt_do = (!empty($v_do) && !in_array($v_do, ['n', 'nee', '0']));

$t_key = 'zonder';
if ($l_mp >= 150000) { $t_key = 'nat3'; }
elseif ($l_mp >= 100000) { $t_key = 'nat2'; }
elseif ($l_mp >= 60000) { $t_key = 'nat1'; }
elseif ($l_mp >= 30000) { $t_key = 'nat'; }
elseif ($l_mp >= 15000) { $t_key = 'bonds'; }
elseif ($l_mp >= 10000) { $t_key = 'kand'; }
elseif ($l_mp >= 5000) { $t_key = 'regio'; }
elseif ($l_mp >= 2000) { $t_key = 'dist'; }
elseif ($l_mp >= 500) { $t_key = 'club'; }

$dagen_check = ['MA' => $speelt_ma, 'WO' => $speelt_wo, 'DO' => $speelt_do];
$speelt_ergens = false;

foreach ($dagen_check as $dag => $speelt) {
if ($speelt) {
$speelt_ergens = true;
$stats[$dag]['tot']++; $titels_teller[$t_key][$dag]++;
if ($is_man) { $stats[$dag]['m']++; } else { $stats[$dag]['v']++; }
if ($is_veen) { $stats[$dag]['veen']++; }
$stats[$dag]['mp'] += $l_mp; $stats[$dag]['r'] += $l_r;
if ($has_geb) { $stats[$dag]['l_tot'] += $l_leeftijd; $stats[$dag]['l_tel']++; }
if ($has_jaren) { $stats[$dag]['j_tot'] += $l_jaren; $stats[$dag]['j_tel']++; }
}
}

if ($speelt_ergens) {
$stats['TOT']['tot']++; $titels_teller[$t_key]['TOT']++;
if ($is_man) { $stats['TOT']['m']++; } else { $stats['TOT']['v']++; }
if ($is_veen) { $stats['TOT']['veen']++; }
$stats['TOT']['mp'] += $l_mp; $stats['TOT']['r'] += $l_r;
if ($has_geb) { $stats['TOT']['l_tot'] += $l_leeftijd; $stats['TOT']['l_tel']++; }
if ($has_jaren) { $stats['TOT']['j_tot'] += $l_jaren; $stats['TOT']['j_tel']++; }
}
}
}

$t_tot = max($stats['TOT']['tot'], 1); $m_tot = max($stats['MA']['tot'], 1); $w_tot = max($stats['WO']['tot'], 1); $d_tot = max($stats['DO']['tot'], 1);

$titels_data = [
['titel' => 'zonder titel', 'mp' => '0', 'MA' => $titels_teller['zonder']['MA'], 'WO' => $titels_teller['zonder']['WO'], 'DO' => $titels_teller['zonder']['DO'], 'TOT' => $titels_teller['zonder']['TOT']],
['titel' => 'Clubmeester', 'mp' => '500', 'MA' => $titels_teller['club']['MA'], 'WO' => $titels_teller['club']['WO'], 'DO' => $titels_teller['club']['DO'], 'TOT' => $titels_teller['club']['TOT']],
['titel' => 'Districtsmeester', 'mp' => '2.000', 'MA' => $titels_teller['dist']['MA'], 'WO' => $titels_teller['dist']['WO'], 'DO' => $titels_teller['dist']['DO'], 'TOT' => $titels_teller['dist']['TOT']],
['titel' => 'Regionaalmeester', 'mp' => '5.000', 'MA' => $titels_teller['regio']['MA'], 'WO' => $titels_teller['regio']['WO'], 'DO' => $titels_teller['regio']['DO'], 'TOT' => $titels_teller['regio']['TOT']],
['titel' => 'Kand. Bondsmeester', 'mp' => '10.000', 'MA' => $titels_teller['kand']['MA'], 'WO' => $titels_teller['kand']['WO'], 'DO' => $titels_teller['kand']['DO'], 'TOT' => $titels_teller['kand']['TOT']],
['titel' => 'Bondsmeester', 'mp' => '15.000', 'MA' => $titels_teller['bonds']['MA'], 'WO' => $titels_teller['bonds']['WO'], 'DO' => $titels_teller['bonds']['DO'], 'TOT' => $titels_teller['bonds']['TOT']],
['titel' => 'Nationaal Meester', 'mp' => '30.000', 'MA' => $titels_teller['nat']['MA'], 'WO' => $titels_teller['nat']['WO'], 'DO' => $titels_teller['nat']['DO'], 'TOT' => $titels_teller['nat']['TOT']],
['titel' => 'Nat. Meester 👑', 'mp' => '60.000', 'MA' => $titels_teller['nat1']['MA'], 'WO' => $titels_teller['nat1']['WO'], 'DO' => $titels_teller['nat1']['DO'], 'TOT' => $titels_teller['nat1']['TOT']],
['titel' => 'Nat. Meester 👑👑', 'mp' => '100.000', 'MA' => $titels_teller['nat2']['MA'], 'WO' => $titels_teller['nat2']['WO'], 'DO' => $titels_teller['nat2']['DO'], 'TOT' => $titels_teller['nat2']['TOT']],
['titel' => 'Nat. Meester 👑👑👑', 'mp' => '150.000', 'MA' => $titels_teller['nat3']['MA'], 'WO' => $titels_teller['nat3']['WO'], 'DO' => $titels_teller['nat3']['DO'], 'TOT' => $titels_teller['nat3']['TOT']]
];
 
Graag in code blokken!
 
$max_vals = ['MA' => 0, 'WO' => 0, 'DO' => 0, 'TOT' => 0];
foreach ($titels_data as $t_item) {
if ($t_item['MA'] > $max_vals['MA']) $max_vals['MA'] = $t_item['MA'];
if ($t_item['WO'] > $max_vals['WO']) $max_vals['WO'] = $t_item['WO'];
if ($t_item['DO'] > $max_vals['DO']) $max_vals['DO'] = $t_item['DO'];
if ($t_item['TOT'] > $max_vals['TOT']) $max_vals['TOT'] = $t_item['TOT'];
}

ob_start(); ?>
<style>
.stat-wrap { font-family: sans-serif; color: #000; }
.v-tabel { border-collapse: collapse; background: #fff; border: 1.5px solid #000; }
.v-tabel th { position: sticky !important; top: 95px !important; z-index: 999 !important; background: #00adef !important; color: #fff !important; padding: 4px !important; font-weight: 700; }
.v-tabel td { padding: 4px 10px !important; border: 1px solid #ccc !important; text-align: center; font-size: 14px; }
.col-title { text-align: left !important; padding-left: 15px !important; }
.col-tot { background: #f7f7f7 !important; font-weight: 700 !important; border-left: 1.5px solid #000 !important; }
.stat-divider { border-bottom: 2.5px solid #000; margin: 30px 0; width: 1040px; }
.perc { color: #ff5252; font-size: 11px; margin-left: 4px; }
.row-accent { background: #eee !important; font-weight: 700 !important; }
.indent { padding-left: 25px !important; }
.high-cell { background: #fff59d !important; font-weight: 700 !important; }
</style>

<div class="stat-wrap">
<div style="display:flex; gap:30px; flex-wrap:wrap; margin-bottom:20px;">
<div>
<h2>Mijn Mijlpaal</h2>
<table class="v-tabel" style="width:550px; height:135px;">
<tr>
<td style="padding:15px!important; text-align:left; line-height:1.6;">
Beste <strong><?php echo $user->display_name; ?></strong>, je hebt momenteel <strong><?php echo number_format($mp,0,',','.'); ?></strong> meesterpunten.<br>
Voor de titel <strong><?php echo $voluest; ?></strong> heb je nog <strong><?php echo number_format($nodig,0,',','.'); ?></strong> nodig, met je gemeten scores zal dat ongeveer in <span style="text-decoration:underline; font-weight:700;"><?php echo $prognose; ?></span> zijn.
</td>
</tr>
</table>
</div>
<div>
<h2>Mijn Gegevens</h2>
<table class="v-tabel" style="width:450px; height:135px;">
<tr><td class="col-title" style="width:160px !important;">Lid sinds</td><td style="text-align:left;"><?php echo $lid_datum?:'-'; ?></td></tr>
<tr><td class="col-title">Spelend op</td><td style="text-align:left;"><?php echo $speeldagen; ?></td></tr>
<tr><td class="col-title">Rating</td><td style="text-align:left;"><?php echo $rating; ?></td></tr>
</table>
</div>
</div>

<div class="stat-divider"></div>

<div style="display:flex; gap:30px; flex-wrap:wrap;">
<div>
<h2>Cluboverzicht Titels</h2>
<table class="v-tabel" style="width:550px;">
<thead><tr><th class="col-title">Titel</th><th>M.P.</th><th>MA</th><th>WO</th><th>DO</th><th class="col-tot">TOT</th></tr></thead>
<tbody>
<?php foreach($titels_data as $row):
$c_ma = (int)$row['MA']; $c_wo = (int)$row['WO']; $c_do = (int)$row['DO']; $c_tot = (int)$row['TOT'];

$h_ma = ($c_ma === $max_vals['MA'] && $c_ma > 0) ? 'class="high-cell"' : '';
$h_wo = ($c_wo === $max_vals['WO'] && $c_wo > 0) ? 'class="high-cell"' : '';
$h_do = ($c_do === $max_vals['DO'] && $c_do > 0) ? 'class="high-cell"' : '';
$h_tot = ($c_tot === $max_vals['TOT'] && $c_tot > 0) ? 'class="high-cell col-tot"' : 'class="col-tot"';
?>
<tr>
<td class="col-title"><?php echo esc_html($row['titel']); ?></td>
<td style="color:#666; font-size:11px; text-align:right!important;"><?php echo esc_html($row['mp']); ?></td>
<td <?php echo $h_ma; ?>><?php echo $c_ma; ?><span class="perc"><?php echo round(($c_ma/$m_tot)*100); ?>%</span></td>
<td <?php echo $h_wo; ?>><?php echo $c_wo; ?><span class="perc"><?php echo round(($c_wo/$w_tot)*100); ?>%</span></td>
<td <?php echo $h_do; ?>><?php echo $c_do; ?><span class="perc"><?php echo round(($c_do/$d_tot)*100); ?>%</span></td>
<td <?php echo $h_tot; ?>><?php echo $c_tot; ?><span class="perc" style="color:#777;"><?php echo round(($c_tot/$t_tot)*100); ?>%</span></td>
Bericht automatisch samengevoegd:

wat zijn dat?
 
Graag even editen in codeblokken. Dat maakt het overzichtelijker. Zie de </> knop, selecteer PHP, plak je code daarin. Aan flarden PHP-code heb ik niks.

Ik krijg nu zelfs andere errors. Dus zet het even in een codeblok, of dump het geheel op Pastebin, of nog liever.... Isoleer het probleem zodat je precies weet waar de fout zit.


1778963424453.webp
 
Laatst bewerkt:
Terug
Bovenaan Onderaan