Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hello. I have encountered a situation when the code is correct, but there are problems showing 'edit_order.php' which is in the admin panel.'

here is what I see now
Order Id

Notice: Trying to access array offset on value of type null in /opt/lampp/htdocs/e-shop/admin/edit_order.php on line 58
Order Price

Notice: Trying to access array offset on value of type null in /opt/lampp/htdocs/e-shop/admin/edit_order.php on line 63
Order Status
Notice: Trying to access array offset on value of type null in /opt/lampp/htdocs/e-shop/admin/edit_order.php on line 71 >Not paid>
Order Date

Notice: Trying to access array offset on value of type null in /opt/lampp/htdocs/e-shop/admin/edit_order.php on line 80

prepare("SELECT * FROM orders WHERE order_id=?");
	$stmt->bind_param('i', $order_id);
	$stmt->execute();

	$order_result = $stmt->get_result();
	$order = $order_result->fetch_assoc();

} else if (isset($_POST['edit_order'])) {

	$order_status = $_POST['order_status'];
	$order_id = $_POST['order_id'];

	$stmt = $conn->prepare("UPDATE orders SET order_status=? WHERE order_id=?");
	$stmt->bind_param('si', $order_status, $order_id);

	if ($stmt->execute()) {
		header('Location: index.php?order_updated=Order has been updated successfully');
		exit;
	} else {
		header('Location: products.php?order_failure=Error occurred, please try again');
		exit;
	}
} else {
	header('Location: index.php');
	exit;
}
?>

<div class="container-fluid">
    <div class="row" style="min-height: 200px">       

        
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                <h1 class="h2">Dashboard</h1>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group me-2"></div>
                </div>
            </div>

            <h2>Edit Order</h2>
            <div class="table-responsive">

                <div class="mx-auto container">                   

                        <p style="color: rgba(255, 0, 0, 1)"></p>

                        <div class="form-group mt-2">
                            Order Id
                            <p class="my-4"></p>
                        </div>

                        <div class="form-group my-3">
                            Order Price
                            <p class="my-4"></p>
                        </div>                       

                        <div class="form-group my-3">
                            Order Status
                            
                                Not paid>
                                Paid>
                                Shipped>
                                Delivered>                            
                        </div>

                        <div class="form-group my-3">
                            Order Date
                            <p class="my-4"></p>
                        </div>
                        <div class="form-group mt-3">                            
                        </div>                    
                </div>
            </div>
        
    </div>
</div>


What I have tried:

I also tried using $order instead of $r but it didn’t change anything
Posted
Updated 15-Jun-23 7:09am
v2
Comments
Richard MacCutchan 15-Jun-23 12:01pm    
You are trying to access items through a variable that has not been in itialised. I do not know which lines 58, 63, 71 and 80 are, but you should be able to see them. So check what variable reference you are using on each and then work backwards to the statement that should have initialised it.
Andre Oosthuizen 15-Jun-23 12:03pm    
Ok, so which code lines is line 58, 63, 71 and 80? Your error refers to you trying to access an array element using an index, but the array itself is null/empty. Without seeing where it errors, we cannot help as your code is incomplete to make a correction.
Andre Oosthuizen 15-Jun-23 12:04pm    
Ah, got jumped, sorry Richard, same reply...
Richard MacCutchan 15-Jun-23 12:30pm    
No problem, it often happens when two (or more) people pick up the same question at around the same time. And maybe the two answers will make it even clearer what the problem is. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900