Undefined index

Résolu
medboy94 Messages postés 44 Date d'inscription   Statut Membre Dernière intervention   -  
zermat Messages postés 160 Date d'inscription   Statut Membre Dernière intervention   -
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>


A voir également:

2 réponses

jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Bonjour
et d'où vient la variable $data ?
1
medboy94 Messages postés 44 Date d'inscription   Statut Membre Dernière intervention  
 
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   Statut Membre Dernière intervention   16
 
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