ArrayPush error

Warning : array_push() expects parameter 1 to be array, null given in C:\xampp\htdocs\final_ass\Food records.php on line 8

Warning : array_push() expects parameter 1 to be array, null given in C:\xampp\htdocs\final_ass\Food records.php on line 9

<?php
	    session_start();
		//Add new record
		if(isset($_POST['submit'])){
			
			if(isset($_POST['food_name']) && isset($_POST['price_food'])){
				array_push($_SESSION['food_name'], $_POST['food_name']);
				array_push($_SESSION['price_food'], $_POST['price_food']);
		    }
		}

The first thing I would do is see what is in your arrays by

echo "<pre>" . print_r($_SESSION['food_name'], 1) . "</pre>";
echo "<pre>" . print_r($_SESSION['price_food'], 1) . "</pre>";

and so on…

Alright,thanks Mr Strider! It’s working now

Sponsor our Newsletter | Privacy Policy | Terms of Service