Hallo allemaal,

Ik heb in een map genaamd Config een functie staan om afbeeldingen met naam en url te laden

In een ander bestand totaal ergens anders op de website include ik dat bestand en roep ik de functie aan, alleen de 4 variabelen die in die functie zitten kan ik niet lezen. Wie heeft de oplossing???

Hier het stukje code van de function:

function getClublogo($Ytid, $Yuid) {
	global $imgThuis;
	global $imgUit;
	global $naamThuis;
	global $naamUit;
	$sqlThuis = "SELECT * FROM `clublogos` WHERE `club_id` = $Ytid";
	$resThuis = mysqli_query($dbcon00, $sqlThuis);
	
	if (mysqli_num_rows($resThuis) > 0) {
 		// output data of each row
 		while($rowThuis = mysqli_fetch_assoc($resThuis)) { 
			$imgThuis = $rowThuis['logo_url'];
			$naamThuis = $rowThuis['clubnaam'];
		}
	}
	//------------------------------------------------------------------//
	$sqlUit = "SELECT * FROM `clublogos` WHERE `club_id` = $Yuid";
	$resUit = mysqli_query($dbcon00, $sqlUit);
	if (mysqli_num_rows($resUit) > 0) {
 		// output data of each row
 		while($rowUit = mysqli_fetch_assoc($resUit)) { 
			$imgUit = $rowUit['logo_url'];
			$naamUit = $rowUit['clubnaam'];
		}
	}
	
	
}


En hier de code voor het terug halen:


include("Config/afbeeldingen.php");
$th = '15';
$ui = '64';
getClublogo($th, $ui);

echo '<br><br>Club ' .$naamThuis. ' (<img src="' .$Ssite. '/'.$imgThuis. '" width="75"> )<br>' ;
echo 'Club ' .$naamUit. ' (<img src="' .$Ssite. '/'.$imgUit. '" width="75"> )<br>' ;


Als ik de functie qua code kopieƫr en plak in de originele broncode dan doet ie het heel keurig...
Waar moeten die variabelen vandaan komen?
vanuit de functie santhe.
De variabelen $imgThuis, $naamThuis, $imgUit, $naamUit
Definieer ze eens voor de include().

Dus:
$imgThuis = '';
etc.
include(..);

<?php 

	$imgThuis;
	$imgUit;
	$naamThuis;
	$naamUit;
	
	include("Config/afbeeldingen.php");
	include("Config/config.php");
// Start gegevens:
session_start();
$_SESSION["sessionWebsite"] = "http://" . $_SERVER['SERVER_NAME'];

$Ssite = $_SESSION["sessionWebsite"];

echo $Ssite;
$th = '15';
$ui = '64';
getClublogo($th, $ui);

echo '<br><br>Club ' .$naamThuis. ' (<img src="' .$Ssite. '/'.$imgThuis. '" width="75"> )<br>' ;
echo 'Club ' .$naamUit. ' (<img src="' .$Ssite. '/'.$imgUit. '" width="75"> )<br>' ;


?>


geeft geen verbetering.
Niet $imgThuis;
Maar $imgThuis = '';
had ik daarna snel aangepast weer, maar ook geen verbetering.
En $dbcon00 zal niet bekend zijn in de function().
die zit in het config bestand met een include...


<?php 
	include("config.php");

	$imgThuis = '';
	$imgUit = '';
	$naamThuis = '';
	$naamUit = '';
// Start gegevens:
session_start();

function getClublogo($Ytid, $Yuid) {
	global $imgThuis;
	global $imgUit;
	global $naamThuis;
	global $naamUit;
	
	$sqlThuis = "SELECT * FROM `clublogos` WHERE `club_id` = $Ytid";
	$resThuis = mysqli_query($dbcon00, $sqlThuis);
	
	if (mysqli_num_rows($resThuis) > 0) {
 		// output data of each row
 		while($rowThuis = mysqli_fetch_assoc($resThuis)) { 
			$imgThuis = $rowThuis['logo_url'];
			$naamThuis = $rowThuis['clubnaam'];
		}
	}
	//------------------------------------------------------------------//
	$sqlUit = "SELECT * FROM `clublogos` WHERE `club_id` = $Yuid";
	$resUit = mysqli_query($dbcon00, $sqlUit);
	if (mysqli_num_rows($resUit) > 0) {
 		// output data of each row
 		while($rowUit = mysqli_fetch_assoc($resUit)) { 
			$imgUit = $rowUit['logo_url'];
			$naamUit = $rowUit['clubnaam'];
		}
	}
	return $imgThuis;
	
}
?>

in de config file staat de $dbcon00
Dan moet die in de function() een global worden gemaakt.

Reageren