Erreur de type Warning: in_array() [function.in-array]

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Erreur de type Warning: in_array() [function.in-array]

Solution to edit_orders

par alfonsoabas » 08 avr. 2009, 16:12

I'm sorry, I will answer in english (not very good because I come from Spain).
This error is not documented in the forum of oscommerce, but I found the solution.
This error is because the function in-array needs an array in the second parameter, but that parameter is not declared as array in the archive edit_orders.php. You need to edit "edit_orders.php" (is in the path: "/htdocs/catalog/admin") and near the line 355 find this text:

$new_order_totals = array();


Add after this line theese others:

$written_ot_totals_array = array();
$written_ot_titles_array = array();


Save the changes and the edition of orders will be fine
:-)

par ouckileou » 02 juin 2008, 22:42

Modération :
royal38, afin d'améliorer la lisibilité de ton message,
pense à utiliser les balises [code] ou [php] (selon le langage utilisé).

Elles sont disponibles au-dessus de la zone de saisie de ton message
lorsque tu postes un nouveau message.

Des indications sont disponibles sur la manière de mettre en forme vos messages dans la FAQ


Les 2 premières erreurs sont assez explicites : "type de donnée incorrect pour le second paramètre passé à in_array()"

Dans la doc : in_array() , on voit que le second paramètre doit être un tableau. Manifestement dans ton code ce n'en sont pas.

Utilise var_dump() pour vérifier le type des 2 variables passées en second paramètre des appels à in_array ligne 423.

La troisième erreur découle des précédentes, à cause des messages d'erreur il y a du texte envoyé au navigateur, ce qui fait planter la fonction header() . Voir la doc encore une fois :
N'oubliez jamais que header() doit être appelée avant que le moindre contenu ne soit envoyé, soit par des lignes HTML habituelles dans le fichier, soit par des affichges PHP. Une erreur très classique est de lire un fichier avec include() ou require(), et de laisser des espaces ou des lignes vides, qui génèreront un affichage avant que la fonction header() ne soit appelée. Le même problème existe avec les fichiers PHP/HTML standards.

Erreur de type Warning: in_array() [function.in-array]

par royal38 » 02 juin 2008, 22:31

Bonjour à tous,

Je fais appel à vous, grand maitre du Php :agenouille: , pour résoudre un problème sur lequelle je suis depuis un bon moment et qui me rend fou :tir2: :axe: :wink:

J'ai un site qui utilise Oscommerce.

J'ai installé une contribution appelé "order editor". Tout fonctionne parfaitement mise à part le fait que j'ai une page d'erreur à un moment donnée :-#

Voici l'erreur que j'ai :
Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/xxxxxxxx/public_html/adminxxxxx/edit_orders.php on line 423

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/xxxxxxxxx/public_html/adminxxxxx/edit_orders.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/adminxxxxxx/edit_orders.php:423) in /home/xxxxxxxx/public_html/adminxxxxx/includes/functions/general.php on line 86

Voici la ligne 423 de edit_orders.php :
if ( (!in_array($ot_class, $written_ot_totals_array)) && (!in_array($ot_title, $written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7
Voici la ligne 423 avec une partie de code autour :
			  } elseif ($new_ot_total) { //also within 6
				$order->info['total'] += ($order_totals[$i]['value']*(-1));
				$current_ot_totals_array[] = $order_totals[$i]['code'];
				$written_ot_totals_array[] = $ot_class;
				$written_ot_titles_array[] = $ot_title;
			  }//end 6
		   }//end 4
		 } elseif ( (tep_not_null($ot_value)) && (tep_not_null($ot_title)) ) { // this modifies if (!strstr($ot_class, 'ot_custom')) { //3
			$new_order_totals[] = array('title' => $ot_title,
					 'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
										'value' => $ot_value,
										'code' => 'ot_custom_' . $j,
										'sort_order' => $j);
			$order->info['total'] += $ot_value;
			$written_ot_totals_array[] = $ot_class;
			$written_ot_titles_array[] = $ot_title;
			$j++;
		  } //end 3
		  
			//save ot_skippy from certain annihilation
			 if ( (!in_array($ot_class, $written_ot_totals_array)) && (!in_array($ot_title, $written_ot_titles_array)) && (tep_not_null($ot_value)) && (tep_not_null($ot_title)) && ($ot_class != 'ot_tax') && ($ot_class != 'ot_loworderfee') ) { //7
			//this is supposed to catch the oddball components that don't show up in $order_totals
				 
					$new_order_totals[] = array(
							'title' => $ot_title,
							'text' => $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']),
							'value' => $ot_value,
							'code' => $ot_class,
							'sort_order' => $j);
			   //$current_ot_totals_array[] = $order_totals[$i]['code'];
				//$current_ot_titles_array[] = $order_totals[$i]['title'];
				$written_ot_totals_array[] = $ot_class;
				$written_ot_titles_array[] = $ot_title;
				$j++;
				 
				 } //end 7


Voila une partie de code de general.php. La ligne 86 correspond à :
	header('Location: ' . $url);
// Redirect to another page or site
  function tep_redirect($url) {
	global $logger;

	if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) {
	  tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
	}

	header('Location: ' . $url);

	if (STORE_PAGE_PARSE_TIME == 'true') {
	  if (!is_object($logger)) $logger = new logger;
	  $logger->timer_stop();
	}

	exit;
  }

////


Pouvez-vous m'aider à solutionner le problème? :-k :wink:

Le pire dans tout ca, c'est que quand j'ai l'erreur qui s'affiche et que je fait un retour à la page précédente, les informations ont bien été mise à jour. #-o


Si vous avez besoin d'autres infos n'hesitez pas. Merci pour votre aide :pouce: