Having Trouble Pulling a single value out and posting it into another table

Currently it is displaying “array” where the title of the movie should be going.

include ('../BrewCity/Includes/brewheader.php');
	require_once ('Brew_City_Connect.php');
	$member_id= $_SESSION['member_id'];
	$movie_id=$_GET['movie_id'];
	$title = ['title'];
	$query = "SELECT title FROM New_Movie_Entry WHERE movie_id='$movie_id' limit 1";
	$result = mysqli_query ($dbc, $query);
	$query = "INSERT INTO Rented_Movies (member_id, movie_id, title)
	VALUES ('$member_id', '$movie_id', '$title')";
	$result = mysqli_query ($dbc, $query);
	if ($result) {
		echo "<p> You have rented a new ".$title;"! </p>";
		echo "<p> Please click here to return to homepage. <a href=https://tytplumb.uwmsois.com/BrewCity/BREW%20CITY%20RENTALS> Here </a>";
		exit();
	} else {

The Rented_Movies table should only hold unique information about the rental - who rented the movie (member_id), what they rented (movie_id), when they rented it (a data/time value), where they rented it (if there is more than one location), and any other unique information about the rental, such as the rental period.

You should not duplicate information. Knowing the movie_id lets you find all the other information about the movie.

Next, don’t put external/unknown data directly into sql query statements. If you are doing that as part of a learning exercise, learn and use prepared queries.

Oh ok makes sense, yes I doing this as part of a learning exercise. I just thought it might look better if the title were there as well. However that makes alot of sense as well. About the queries i was using prepared, however I have been switching up the queries for the past couple days to get it to work like that.

Thank you for the reply!

Sponsor our Newsletter | Privacy Policy | Terms of Service