Beste forum

ik heb volgend probleem aan de hand
in de error log van mijn server (draait php 5.4) krijgt ik tonnen foutmeldingen

ik heb me al suf gezocht naar de oorzaak maar kan niets vinden
kan iemand van jullie me verder helpen?
onze vriend google heeft me ook al laten weten dat ik met een probleem zit

hieronder de foutmeldingen : dit gaat dus 104 mb aan 1 stuk door




Sat Jan 24 10:14:17 2015] [error] [client 157.55.39.88] File does not exist: /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving1088-promo_Voetdimmer_tci__cd 
 [Sat Jan 24 10:14:21 2015] [warn] [client 207.46.13.81] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:22 2015] [warn] [client 207.46.13.81] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:31 2015] [warn] [client 207.46.13.56] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:33 2015] [warn] [client 207.46.13.56] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:34 2015] [warn] [client 66.249.78.106] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:34 2015] [warn] [client 207.46.13.56] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:36 2015] [warn] [client 207.46.13.56] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server 
 [Sat Jan 24 10:14:36 2015] [error] [client 207.46.13.56] Premature end of script headers: beschrijving.php 
 [Sat Jan 24 10:14:37 2015] [warn] [client 207.46.13.81] mod_fcgid: stderr: PHP Strict Standards: Only variables should be passed by reference in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 990 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 862 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Warning: sort() expects parameter 1 to be array, null given in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 870 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:42 2015] [warn] [client 207.46.13.106] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 
 [Sat Jan 24 10:14:46 2015] [warn] [client 207.46.13.106] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server 
 [Sat Jan 24 10:14:46 2015] [error] [client 207.46.13.106] Premature end of script headers: beschrijving.php 
 [Sat Jan 24 10:14:46 2015] [warn] [client 157.55.39.88] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 862 
 [Sat Jan 24 10:14:46 2015] [warn] [client 157.55.39.88] mod_fcgid: stderr: PHP Warning: sort() expects parameter 1 to be array, null given in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 870 
 [Sat Jan 24 10:14:46 2015] [warn] [client 157.55.39.88] mod_fcgid: stderr: PHP Notice: Undefined variable: productsIntoCategory in /var/www/vhosts/onderdelenvoorhuishoudtoestellen.be/httpdocs/beschrijving.php on line 903 



hieronder de code :

<?php
if($displayProductsList=="oui" AND $displayProductsListNum>0) {
	$productsIntoCategory2 = $productsIntoCategory;
	if(!isset($_GET['i'])) $_GET['i']=0;
	if(isset($_GET['i']) AND $_GET['i']<0) $_GET['i']=0;
	 
     
     
    
	$addToQuery2Z = "";
	sort($productsIntoCategory2);
	$productsNum = count($productsIntoCategory2);
	if($productsNum > 0) {
		$addToQuery2Z.=" pr.products_id IN(";
		$uu = 1;
		foreach($productsIntoCategory2 AS $elem) {
			$addToQuery2Z.= "'".$elem."',";
			$prodId[$uu++] = $elem;
		}
		$addToQuery2Z.= ") ";
	}
	else {
		$addToQuery2Z= 1;
	}
	$addToQuery2Z = str_replace(",)",")",$addToQuery2Z);
	## Carousel request
	$CarQuery = mysql_query("SELECT pr.products_id, pr.products_image, pr.products_name_".$_SESSION['lang'].", pr.products_forsale, pr.products_price, sp.specials_new_price, sp.specials_last_day, sp.specials_first_day, sp.specials_visible,
							IF(sp.products_id<>'null'
                        	AND TO_DAYS(sp.specials_first_day) <= TO_DAYS(NOW())
                        	AND TO_DAYS(NOW()) <= TO_DAYS(sp.specials_last_day) , 'oui','non') as toto
							FROM products as pr
							LEFT JOIN specials as sp
                          	ON (pr.products_id = sp.products_id)
							WHERE ".$addToQuery2Z." 
							AND pr.products_visible='yes'
							ORDER BY pr.products_id DESC LIMIT ".$_GET['i'].",".$displayProductsListNum."") or die (mysql_error());
	$tototalZ = mysql_num_rows($CarQuery);
	if($tototalZ>0) {
		$productList="";
		$i=100;
		$theme = array("C0C0C0", $backGdColorListLine);
		$e = 0;
		while($carResult = mysql_fetch_array($CarQuery)) {
      		if(count($productsIntoCategory) > 1) {
      			## products IDs
				$productsIds[] = $carResult['products_id'];
				## Display product image
				$displayProductInfo = "<div align='center'><img src='im/zzz.gif' width='1' height='15' border='0'></div>";
				$displayProductInfo.= "<div align='center'>- ".array_search($carResult['products_id'], $prodId)." ".strtolower(DE)." ".$productsNum." -</div>";
				$displayProductInfo.= "<div align='center'><img src='im/zzz.gif' width='1' height='5' border='0'></div>";
				$displayProductInfo.= "<div align='center'>";
				if($gdOpen == "non") {
      			    $images_widthDesc2 = abs($ImageSizeDesc-70);
        			$hZ = @getimagesize($carResult['products_image']);
        			if(!$hZ) $carResult['products_image']="im/zzz_gris.gif";
        			$image_desc2 = resizeImage($carResult['products_image'],$ImageSizeDesc,$images_widthDesc2);
					$displayProductInfo.= "<img src='".$carResult['products_image']."' border='0' width='".$image_desc2[0]."' height='".$image_desc2[1]."' alt='".$carResult['products_name_'.$_SESSION['lang']]."'>";
				}
				else {
					$images_widthDesc2 = abs($ImageSizeDesc-70);
					$hZ = @getimagesize($carResult['products_image']);
					if(!$hZ) $carResult['products_image']="im/zzz_gris.gif";
					$image_desc2 = infoImageFunction($carResult['products_image'],$images_widthDesc2,$ImageSizeDesc);
					$displayProductInfo.= "<img src='mini_maker.php?backColor=".$backGdColor."&extension=".$image_desc2[0]."&imageSource=".$carResult['products_image']."&largeurOrigin=".$image_desc2[1]."&hauteurOrigin=".$image_desc2[2]."&largeur=".$image_desc2[3]."&hauteur=".$image_desc2[4]."' alt='".$carResult['products_name_'.$_SESSION['lang']]."' title='".$carResult['products_name_'.$_SESSION['lang']]."' border='0'>";
				}
				$displayProductInfo.= "</div>";
      			$displayProductInfo.= "<div align='center'><img src='im/zzz.gif' width='1' height='5' border='0'></div>";
  
      			$displayProductInfo.= "<div align='center'><u>".$carResult['products_name_'.$_SESSION['lang']]."</u></div>";
 
				if($carResult['toto']=='oui') {
					$priceZ = $carResult['specials_new_price'];
					$displayPriceZ = "<div align='center'><img src='im/zzz.gif' width='1' height='10' border='0'></div>";
					$displayPriceZ.= "<div style='font-size:11px'><b><s>".$carResult['products_price']." ".$symbolDevise."</s></b></div>";
					$displayPriceZ.= "<div class='PromoFontColorNumber' style='font-size:11px'><b>".$priceZ." ".$symbolDevise."</b></div>";
				}
				else {
					$priceZ = $carResult['products_price'];
					$displayPriceZ = "<div align='center'><img src='im/zzz.gif' width='1' height='10' border='0'></div>";
					$displayPriceZ.= "<div style='font-size:11px'><b>".$priceZ." ".$symbolDevise."</b></div>";
				}
				if($priceZ=="0.00") $displayPriceZ="";
				if((isset($_SESSION['account']) OR $displayPriceInShop=='oui') AND $carResult['products_forsale']=="yes") {
					$displayProductInfo.= "<div align='center'>".$displayPriceZ."</div>";
					if(isset($_SESSION['reduc']) AND $_SESSION['reduc'] > 0) {
						$displayProductInfo.= ($priceZ!=="0.00")? "<div align='center'>".VOTRE_PRIX.": <span class='PromoFontColorNumber' style='font-size:11px'><b>".newPrice($priceZ,$_SESSION['reduc'])."&nbsp;".$symbolDevise."</b></span></div>" : "";
					}
					if($devise2Visible=="oui" AND $priceZ>0) $displayProductInfo.= curPrice($priceZ,$symbolDevise2,"center");
				}
				$displayProductInfo.= "<div align='center'><img src='im/zzz.gif' width='1' height='10' border='0'></div>";
 
				$boxWidth = ($gdOpen == "non")?  $boxWidth = $image_desc2[0]+35 : $boxWidth = $image_desc2[3]+35;
 
				$boxposition = $boxWidth/2;
  
				$urlBox = str_replace("id=".$_GET['id'], "id=".$carResult['products_id'] ,$_SERVER["QUERY_STRING"]);
 
				$top = "top:10px; ?top:10px;"; 
 
				$productList.= "<a href='beschrijving.php?".$urlBox."' class='tooltip2'>";
				if(isset($_GET['id']) AND $_GET['id']==$carResult['products_id']) {
					$productList.= "<b><span class='fondSelectedProduct'>";
				}
				else {
					$e = $e+1;
					if(($e%2) == 0) $ooo=1; else $ooo=0;
 
					$productList.= "<b><span style='background-color:#".$theme[$ooo]."'>";
				}
				$productList.= "<img src='im/zzz.gif' width='8' height='10' border='0'>";
				$productList.= "</b></span>";
				$productList.= "<em style='width:".$boxWidth."px; left:-".$boxposition."px; ".$top.";'><div align='left'>".$displayProductInfo."</div></em>";
				$productList.= "</a>";
			}
    	}
    	
    	if(isset($productsIds) AND count($productsIds)>0 AND isset($productsIntoCategory2)) {
			sort($productsIds); 
    		$_SESSION['ActiveUrl'] = redirectionZ("i",$_GET['i']);
    		if(isset($_SERVER["QUERY_STRING"])  AND $_SERVER["QUERY_STRING"]!=="" AND strstr($_SESSION['ActiveUrl'],"?")) $slash2 = "&"; else $slash2 = "?";

 
				$lastProductsIds = $displayProductsListNum;
				if(isset($_GET['i']) AND $_GET['i']>0) $lastProductsIds = $lastProductsIds+$_GET['i'];
				$previousLastProductsIds = $lastProductsIds-$displayProductsListNum;
                $nextCarousel = "<img src='im/zzz.gif' width='5' height='1' border='0'><a href='".$_SESSION['ActiveUrl'].$slash2."i=".$lastProductsIds."'>";
				$nextCarousel.= "<img src='im/next.png' alt='".SUIVANTTT."' title='".SUIVANTTT."' border='0'>";
				$nextCarousel.= "</a>";
                if($lastProductsIds>=$productsNum) $nextCarousel="";
  
                $numProductsInList = end(array_keys($productsIds))+1;
                $previousProductsIds = $previousLastProductsIds-$displayProductsListNum;
                if($nextCarousel=="") $previousProductsIds = $productsNum-$displayProductsListNum-$numProductsInList;
                if($previousProductsIds<0) $previousProductsIds=0;
                $prevCarousel = "<a href='".$_SESSION['ActiveUrl'].$slash2."i=".$previousProductsIds."'>";
				$prevCarousel.= "<img src='im/prev.png' alt='".PRECEDENT."' title='".PRECEDENT."' border='0'>";
				$prevCarousel.= "</a><img src='im/zzz.gif' width='5' height='1' border='0'>";
                if($previousLastProductsIds<=0) $prevCarousel="";
    	}
    	
    	 
    	if(isset($productList) AND $productList!=="") {
    		if($activeRoundedCornersDesc=='yes') $tableCenter="center"; else $tableCenter="right";
	    	print "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='".$tableCenter."' valign='bottom'>";
			print $prevCarousel.$productList.$nextCarousel;
			print "</td></tr></table>";
		}
	}
}
?>
Zou je willen aangeven waar de bewuste regels zijn, en kan je de code tussen [code] en [/code]-tags plaatsen, dan is alles beter leesbaarder.


Die 'Undefined variable' is makkelijk af te vangen d.m.v. http://php.net/isset
Verder zouden een aantal tab's zeker niet misstaan in deze 'code-brei'.
Gelukkig hebben we ook code-tags, zoals ik net uitlegde. Ik zal ze wel even plaatsen.
Ik vind dit een beetje apart:
$productsIntoCategory2 = $productsIntoCategory;

Wat is nou het verschil tussen beide variabelen die je gebruikt?
Je kan verder met:
<?php
if(isset($productsIntoCategory2,$productsIntoCategory)) {
//voer hier je script uit
}
?>
[/code]
Controleren of deze variabelen bestaan.
Je 1e regel van de foutmelding lijkt me duidelijk ;) Een bepaalde file bestaat niet.

Veel foutmeldingen zou je met Google toch echt info over moeten kunnen vinden.

Undefined variable: productsIntoCategory --> variabele bestaat niet/is onbekend.

Warning: sort() expects parameter 1 to be array, null given --> Kennelijk is $productsIntoCategory2 geen array.
Passed by reference: je geeft een functie als argument iets mee dat geen var is.

Bijv
<?php $x = end(range(1,100)); ?>

Ipv
<?php
$a = range(1,100);
$x = end($a);
?>

dit omdat hier bij niet alleen $x een waarde krijgt, maar ook het laatste array element current wordt.

(Iets waar ik de afgelopen 10 jaar nog geen toepassing voor had, masr zo werkt die functie)
Het lijken veel foutmeldingen, maar ik tel er maar 7 verschillende in je fragment. Als je 1 fout oplost scheelt dit vervolgens meerdere errorlog-regels (mogelijk zelfs per request).

Errorlogs zijn enorm leerzaam, en bij PHP wijzen ze meestal direct naar de plek waar er dingen misgaan dus ik vermoed dat er problemen zijn met de interpretatie ervan?

Mijn eerste vraag zou zijn: heb je deze code zelf geschreven, heb je dit door iemand anders laten doen of heb je deze ergens vandaan geplukt?

Iets wat mij opvalt: er zit nagenoeg geen annotatie in deze code. Als je code niet zelf schrijft kan dit een handig aanknopingspunt zijn, maar ja, hier zul je dus door de code heen moeten ploeteren.

Deze code lijkt ook enigszins gedateerd (gebruik van mysql_query?) en onveilig (script lijkt vatbaar voor SQL-injectie). Daarnaast kan enige refactoring ook geen kwaad:

<?php
$addToQuery2Z.=" pr.products_id IN(";
$uu = 1;
foreach($productsIntoCategory2 AS $elem) {
    $addToQuery2Z.= "'".$elem."',";
    $prodId[$uu++] = $elem;
}
$addToQuery2Z.= ") ";
?>


-->

<?php
$addToQuery2Z = ' pr.products_id IN ('.implode(',', $productsIntoCategory2).')';
$prodId = array_values($productsIntoCategory2); // maar dan vanaf index 0
?>


Je zou je ook kunnen afvragen waarom je de informatie in $productsIntoCategory2 (die zelf ook al een kopie is) weer wilt kopieren :/.

Tijd voor een grondige opschoon-ronde?
de code heb ik niet zelf geschreven. ze is aangekocht als webshoppakket in 2012.
de ontwerper is jammer genoeg overleden, op hem kan ik dus geen beroep meer doen.

de code is nog geschreven voor een oudere versie van php. kan dit daar iets mee te maken hebben?

Hm, ik vermoed dat het toch iets meer in de hoek zit van "in hoog tempo geschreven" en/of "niet goed getest", PHP-versie heeft er niet eens zoveel mee te maken denk ik.

Reageren