php webpage help

This is the code I’ve written for the front end application for my database. The error I’m getting when calling this page is

( ! ) Parse error: syntax error, unexpected ‘;’ in C:\wamp\www\354\BMH14896\project website\new_order2.php on line 19

Ive put line 19 in red (line 29 in the posted code)

[php]<!doctype html>

Inserting Order

<?php include "config.php"; $c = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Connection failed: " . mysqli_connect_error());
    $quantity = $_POST['quantity'];
	$product_name = $_POST['product_name'];
	$name = explode(" ", $_POST['name'];
	$f_name = $name[0];
	$l_name = $name[1];
	
	$query = "SELECT product_id, price
			  FROM product
			  WHERE product_name = '$product_name'";
	$results = mysqli_query($c, $query) or die("Query failed: " . mysqli_error($c));
	$product = mysqli_fetch_array($results);
	mysqli_free_result($results);
	
	$query = "SELECT customer_id
              FROM customer
              WHERE f_name = '$f_name'
	          AND l_name = '$l_name'";

// below is line 19
$results = mysqli_query($c, $query) or die("Query failed: " . mysqli_error($c));
$customer = mysqli_fetch_array($results);
mysqli_free_result($results);

	$query = "INSERT INTO sale (customer_id, product_id, quantity, total_cost, date_occurred)
              VALUES ('$customer[customer_id]', '$product[product_id]', '$quantity', '$quantity * $product[price]', Curdate())";
    mysqli_query($c, $query) or die("Failed to insert order: " . mysqli_error($c));
    echo "Successfully added order";

    mysqli_close($c);
  ?>
</div>
[/php]

Correction on your code, I don’t know why you think line 19 is the issue, when it is on line 12 of what is posted.

Sponsor our Newsletter | Privacy Policy | Terms of Service