Undefined index

Résolu/Fermé
medboy94 Messages postés 44 Date d'inscription jeudi 6 septembre 2012 Statut Membre Dernière intervention 14 mai 2016 - 1 mai 2016 à 10:57
zermat Messages postés 160 Date d'inscription jeudi 19 juin 2014 Statut Membre Dernière intervention 3 juin 2016 - 2 mai 2016 à 09:17
Bonjour , j'ai une erreur Undefined index product_id product_title serve_for product_price category_name product_image dans le tableau .


	$sql_query = "SELECT product_id, product_title, Serve_for, product_price,  cat_title, product_image, product_product_description
		
				FROM products m, categories c
				WHERE m.product_id = ? AND m.product_category_id = c.cat_id";
		
		$stmt = $connect->stmt_init();
		if($stmt->prepare($sql_query)) {	
			// Bind your variables to replace the ?s
			$stmt->bind_param('s', $ID);
			// Execute query
			$stmt->execute();
			// store result 
			$stmt->store_result();
			$stmt->bind_result($data['product_id'], 
					$data['product_title'], 
					$data['Serve_for'], 
					$data['product_price'], 
					$data['Category_name'],
					$data['product_image'],
					$data['product_description']
					);
			$stmt->fetch();
			$stmt->close();
		}
		
	?>

<div class="col-md-9 col-md-offset-2">
	<h1>Menu Detail</h1>
	<form method="post">
		<table table class='table table-bordered table-condensed'>
			<tr class="row">
				<th class="detail">ID</th>
				<td class="detail"><?php echo $data['product_id']; ?></td>
			</tr>
			<tr class="row">
				<th class="detail">Name</th>
				<td class="detail"><?php echo $data['product_title']; ?></td>
			</tr>
				<tr class="row">
				<th class="detail">Status</th>
				<td class="detail"><?php echo $data['Serve_for']; ?></td>
			</tr>
			<tr class="row">
				<th class="detail">product_price</th>
				<td class="detail"><?php echo $data['product_price']." ".$currency; ?></td>
			</tr>
			<tr class="row">
				<th class="detail">Category</th>
				<td class="detail"><?php echo $data['Category_name']; ?></td>
			</tr>
			<tr class="row">
				<th class="detail">Image</th>
				<td class="detail"><img src="<?php echo $data['product_image']; ?>" width="200" height="150"/></td>
			</tr>
			<tr class="row">
				<th class="detail">product_description</th>
				<td class="detail"><?php echo $data['product_description']; ?></td>
			</tr>
		</table>
		
	</form>


2 réponses

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
1 mai 2016 à 11:09
Bonjour
et d'où vient la variable $data ?
1
medboy94 Messages postés 44 Date d'inscription jeudi 6 septembre 2012 Statut Membre Dernière intervention 14 mai 2016
1 mai 2016 à 11:14
merci pour votre réponse j'ai declarer cetter variable au début du code
$data = array();
0
zermat Messages postés 160 Date d'inscription jeudi 19 juin 2014 Statut Membre Dernière intervention 3 juin 2016 16
2 mai 2016 à 09:17
Bonjour
apparemment le résultat de $stmt->prepare($sql_query) est false. Mettez mysqli_report(MYSQLI_REPORT_ALL); en début de votre script pour voir l'erreur
0