Hallo allemaal ik heb een scriptje die de juiste afbeelding moet ophalen enkel doet hij het niet.
Kan iemand mij vertellen wat er niet goed gaat? Alvast bedankt

$h = date('H'); //set variable $h to the hour of the day
$d = date('w'); //set variable $d to the day of the week.
$year = date('Y'); //set variable $year to the current year
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
// Adjust 2 hour offset for MST below.
$h = $h+0;


// MONDAY SCHEDULE
if ($d == 1 && $h >= 0 && $h < 8) $img = 'https://www.hitradiocentraalfm.nl/assets/images/nonstop.png';;
else if ($d == 1 && $h >= 8 && $h < 9) $img = 'https://hitradiocentraalfm.nl/assets/images/eenmaster.png';
else if ($d == 1 && $h >= 9 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 1 && $h >= 13 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/goudkoorts.png';
else if ($d == 1 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/demuziekfabriek.png';
else if ($d == 1 && $h >= 15 && $h < 16) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 1 && $h >= 16 && $h < 17) $img = 'https://hitradiocentraalfm.nl/assets/images/middleoftheroad.png';
else if ($d == 1 && $h >= 17 && $h < 19) $img = 'https://hitradiocentraalfm.nl/assets/images/dekkerradio.png';
else if ($d == 1 && $h >= 19 && $h < 21) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 1 && $h >= 21 && $h < 23) $img = 'https://hitradiocentraalfm.nl/assets/images/winkelwagenshow.png';
else if ($d == 1 && $h >= 21) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 2 && $h < 0) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';

// TUESDAY SCHEDULE
if ($d == 2 && $h >= 0 && $h < 8) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 2 && $h >= 8 && $h < 9) $img = 'https://hitradiocentraalfm.nl/assets/images/eenmaster.png';
else if ($d == 2 && $h >= 9 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 2 && $h >= 13 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/goudkoorts.png';
else if ($d == 2 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/demuziekfabriek.png';
else if ($d == 2 && $h >= 15 && $h < 16) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 2 && $h >= 16 && $h < 17) $img = 'https://hitradiocentraalfm.nl/assets/images/middleoftheroad.png';
else if ($d == 2 && $h >= 17 && $h < 19) $img = 'https://hitradiocentraalfm.nl/assets/images/dekkerradio.png';
else if ($d == 2 && $h >= 19 && $h < 20) $img = 'https://hitradiocentraalfm.nl/assets/images/reggearewindontheblock.png';
else if ($d == 2 && $h >= 20 && $h < 22) $img = 'https://hitradiocentraalfm.nl/assets/images/goudenfoutshow.png';
else if ($d == 2 && $h >= 22) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 3 && $h < 0) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';

// WEDNESDAY SCHEDULE
if ($d == 3 && $h >= 0 && $h < 8) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 3 && $h >= 8 && $h < 9) $img = 'https://hitradiocentraalfm.nl/assets/images/eenmaster.png';
else if ($d == 3 && $h >= 9 && $h < 11) $img = 'https://hitradiocentraalfm.nl/assets/images/robopwoensdag.png';
else if ($d == 3 && $h >= 11 && $h < 12) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 3 && $h >= 12 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/goudkoorts.png';
else if ($d == 3 && $h >= 13 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/oranjetop30herhaling.png';
else if ($d == 3 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/demuziekfabriek.png';
else if ($d == 3 && $h >= 15 && $h < 16) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 3 && $h >= 16 && $h < 17) $img = 'https://hitradiocentraalfm.nl/assets/images/middleoftheroad.png';
else if ($d == 3 && $h >= 17 && $h < 19) $img = 'https://hitradiocentraalfm.nl/assets/images/dekkerradio.png';
else if ($d == 3 && $h >= 19 && $h < 22) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 3 && $h >= 22) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 4 && $h < 0) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';

// THURSDAY SCHEDULE
if ($d == 4 && $h >= 0 && $h < 8) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 4 && $h >= 8 && $h < 9) $img = 'https://hitradiocentraalfm.nl/assets/images/eenmaster.png';
else if ($d == 4 && $h >= 9 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 4 && $h >= 13 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/goudkoorts.png';
else if ($d == 4 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/demuziekfabriek.png';
else if ($d == 4 && $h >= 15 && $h < 16) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 4 && $h >= 16 && $h < 17) $img = 'https://hitradiocentraalfm.nl/assets/images/middleoftheroad.png';
else if ($d == 4 && $h >= 17 && $h < 19) $img = 'https://hitradiocentraalfm.nl/assets/images/dekkerradio.png';
else if ($d == 4 && $h >= 19 && $h < 22) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 4 && $h >= 22 && $h < 23) $img = 'https://www.hitradiocentraalfm.nl/assets/images/tourguidepodcast.png';;
else if ($d == 4 && $h >= 21) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 5 && $h < 0) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';


// FRIDAY SCHEDULE
if ($d == 5 && $h >= 0 && $h < 8) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 5 && $h >= 8 && $h < 9) $img = 'https://hitradiocentraalfm.nl/assets/images/eenmaster.png';
else if ($d == 5 && $h >= 9 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 5 && $h >= 13 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/goudkoorts.png';
else if ($d == 5 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/demuziekfabriek.png';
else if ($d == 5 && $h >= 15 && $h < 16) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 5 && $h >= 16 && $h < 17) $img = 'https://www.hitradiocentraalfm.nl/assets/images/middleoftheroad.png';;
else if ($d == 5 && $h >= 17 && $h < 18) $img = 'https://www.hitradiocentraalfm.nl/assets/images/hadiedave.png';;
else if ($d == 5 && $h >= 18 && $h < 20) $img = 'https://www.hitradiocentraalfm.nl/assets/images/dekkerradio.png';;
else if ($d == 5 && $h >= 20 && $h < 22) $img = 'https://hitradiocentraalfm.nl/assets/images/peterfietsthetweekendin.png';
else if ($d == 5 && $h >= 22) $img = 'https://www.hitradiocentraalfm.nl/assets/images/2uurwhitelion.png';;
else if ($d == 6 && $h < 0) $img = 'https://www.hitradiocentraalfm.nl/assets/images/2uurwhitelion.png';;




// SATURDAY SCHEDULE
if ($d == 6 && $h >= 0 && $h < 14) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 6 && $h >= 14 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/oranjetop30.png';
else if ($d == 6 && $h >= 15 && $h < 17) $img = 'https://hitradiocentraalfm.nl/assets/images/radiospektakel.png';
else if ($d == 6 && $h >= 17 && $h < 19) $img = 'https://hitradiocentraalfm.nl/assets/images/dejaren70.png';
else if ($d == 6 && $h >= 19 && $h < 21) $img = 'https://hitradiocentraalfm.nl/assets/images/hollandsplein.png';
else if ($d == 6 && $h >= 21) $img = 'https://www.hitradiocentraalfm.nl/assets/images/nonstop.png';;
else if ($d == 0 && $h < 0) $img = 'https://www.hitradiocentraalfm.nl/assets/images/nonstop.png';;

// Sunday SCHEDULE
else if ($d == 0 && $h >= 0 && $h < 8) $img = 'https://www.hitradiocentraalfm.nl/assets/images/nonstop.png';;
else if ($d == 0 && $h >= 8 && $h < 10) $img = 'https://hitradiocentraalfm.nl/assets/images/deconnectie.png';
else if ($d == 0 && $h >= 10 && $h < 13) $img = 'https://hitradiocentraalfm.nl/assets/images/hetradiofestijn.png';
else if ($d == 0 && $h >= 13 && $h < 15) $img = 'https://hitradiocentraalfm.nl/assets/images/19toen.png';
else if ($d == 0 && $h >= 15 && $h < 18) $img = 'https://hitradiocentraalfm.nl/assets/images/nonstop.png';
else if ($d == 0 && $h >= 17 && $h < 18) $img = 'https://hitradiocentraalfm.nl/assets/images/dehitkampioen.png';
else if ($d == 0 && $h >= 18 && $h < 20) $img = 'https://hitradiocentraalfm.nl/assets/images/klooienmetvanrooijen.png';
else if ($d == 0 && $h >= 20 && $h < 22) $img = 'https://hitradiocentraalfm.nl/assets/images/baars&co.png';
else if ($d == 0 && $h >= 22) $img = 'https://hitradiocentraalfm.nl/assets/images/danceexspress.png';
else if ($d == 1 && $h < 0) $img = 'https://hitradiocentraalfm.nl/assets/images/danceexpress.png';
?>





<div class="image-wrapper">
<img src="<?php echo $img; ?>" width="1000" height="300">
</div></div>
Een beetje website heeft bescherming tegen ongeautoriseerd gebruik van plaatjes, zoals hotlinking. Waarschijnlijk heb je nog geen permissie van de website eigenaar? Vraag of ze hun webserver kunnen laten meewerken.
Ah, een glazen bol topic!
Wat gebeurt er wel?

En kan je de code tussen code tags plaatsen? Alvast bedankt!
Ad Fundum op 05/11/2022 19:29:23

Een beetje website heeft bescherming tegen ongeautoriseerd gebruik van plaatjes, zoals hotlinking. Waarschijnlijk heb je nog geen permissie van de website eigenaar? Vraag of ze hun webserver kunnen laten meewerken.

Daarbij ga je ervan uit dat de data afkomstig is van een externe website/server. Dat hoeft natuurlijk niet zo te zijn.


[size=xsmall]Toevoeging op 05/11/2022 21:08:29:[/size]

Dat gezegd hebbende ...

>> Kan iemand mij vertellen wat er niet goed gaat?

@Marcel kun je aangeven wát er niet goed gaat? We hebben namelijk geen glazen bol ;-)
Zet else if eens aan elkaar : elseif

[size=xsmall]Toevoeging op 06/11/2022 11:21:18:[/size]

Heb e.e.e. wat aangepast zodat je niet oneindige elseif hoef te doen.

Zelf uitbreiden.

<?php
$h    = date('H'); //set variable $h to the hour of the day
$d    = date('w'); //set variable $d to the day of the week.
$year = date('Y'); //set variable $year to the current year
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
// Adjust 2 hour offset for MST below.
$h   = $h + 0;
$url = 'https://www.hitradiocentraalfm.nl/assets/images/';
echo $h . ', ' . $d . ', ' . $year . '<br />';

$afbeeldingen = [
	'nons' => 'nonstop.png',
	'eenm' => 'eenmaster.png',
	'gouk' => 'goudkoorts.png',
	'demm' => 'demuziekfabriek.png',
	'midd' => 'middleoftheroad.png',
	'dekk' => 'dekkerradio.png',
	'wink' => 'winkelwagenshow.png',
	'regg' => 'reggearewindontheblock.png',
	'gouf' => 'goudenfoutshow.png',
	'robo' => 'robopwoensdag.png',
	'orah' => 'oranjetop30herhaling.png',
	'tour' => 'tourguidepodcast.png',
	'hadi' => 'hadiedave.png',
	'pete' => 'peterfietsthetweekendin.png',
	'uurw' => '2uurwhitelion.png',
	'holl' => 'hollandsplein',
	'deja' => 'dejaren70',
	'radi' => 'radiospektakel',
	'orat' => 'oranjetop30',
	'deco' => 'deconnectie.png',
	'hetr' => 'hetradiofestijn.png',
	'toen' => '19toen.png',
	'dehi' => 'dehitkampioen.png',
	'kloo' => 'klooienmetvanrooijen.png',
	'baar' => 'baars&co.png',
	'danc' => 'danceexspress.png',
];

$afbeeldingen_sort = [
    'toen' => '19toen.png',
    'uurw' => '2uurwhitelion.png',
    'baar' => 'baars&co.png',
    'danc' => 'danceexspress.png',
    'deco' => 'deconnectie.png',
    'dehi' => 'dehitkampioen.png',
    'deja' => 'dejaren70.png',
    'dekk' => 'dekkerradio.png',
    'demm' => 'demuziekfabriek.png',
    'eenm' => 'eenmaster.png',
    'gouf' => 'goudenfoutshow.png',
    'gouk' => 'goudkoorts.png',
    'hadi' => 'hadiedave.png',
    'hetr' => 'hetradiofestijn.png',
    'holl' => 'hollandsplein.png',
    'kloo' => 'klooienmetvanrooijen.png',
    'midd' => 'middleoftheroad.png',
    'nons' => 'nonstop.png',
    'orat' => 'oranjetop30.png',
    'orah' => 'oranjetop30herhaling.png',
    'pete' => 'peterfietsthetweekendin.png',
    'radi' => 'radiospektakel.png',
    'regg' => 'reggearewindontheblock.png',
    'robo' => 'robopwoensdag.png',
    'tour' => 'tourguidepodcast.png',
    'wink' => 'winkelwagenshow.png',
];

echo '<pre>' . print_r( $afbeeldingen, TRUE ) . '</pre>';

echo '<pre>' . print_r( $afbeeldingen_sort, TRUE ) . '</pre>';

$nons = $afbeeldingen['nons'];

$schema = [
	'0' => [
		'22' => 'danc',
		'20' => 'baar',
		'18' => 'kloo',
		'17' => 'dehi',
		'15' => 'nons',
		'13' => 'toen',
		'10' => 'hetr'
	],
	'1' => [
		'23' => 'nons',
		'21' => 'wink',
		'19' => 'nons',
		'17' => 'dekk',
		'16' => 'midd',
		'15' => 'nons',
		'14' => 'demu',
		'13' => 'gouk',
		'9'  => 'nons',
		'8'  => 'eenm',
		'0'  => 'nons',
		],
	'2' => [],
	'3' => [],
	'4' => [],
	'5' => [],
	'6' => [],
];

echo '<pre>' . print_r( $schema, TRUE ) . '</pre>';

//echo '<p>' . $schema[$d][$h] . ' | ' . $afbeeldingen[$schema[$d][$h]] . '</p>';
$tijdblokken = $schema[$d];
$img = $nons;
foreach ( $tijdblokken as $tijd => $afbeelding ):
	if ( $h >= $tijd):
		$img = $afbeeldingen[$afbeelding];
	endif;
endforeach;
?>

<figure style="margin: 0px; max-width: 1000px; background: ivory; text-align: center;">
	<img src = "<?php echo $url . $img; ?>" style = "width: 100%;" />
	<figcaption style="padding: 0.500em;">De huidige uitzending</figcaption>
</figure>

<hr />

<div class="image-wrapper">
	<img src = "<?php echo $url . $img; ?>" style = "max-width: 1000px;" />
</div>


[size=xsmall]Toevoeging op 06/11/2022 11:35:45:[/size]

Aanvulling.
Na regel 112 toevoegen :
break;
Lekker bezig A.S. :-)

Reageren