Good morning, all!

As the title suggests, I am having a syntax error. I'm using Notepad++, and I don't seem to be missing any curly braces.

Is there somthing else I'm missing?

Thank you

<?php
session_start();
include('header.php');


	if((isset($_GET['movie_users_id'])) && (is_numeric($_GET['movie_users_id']))) {
		$movie_users_id = $_GET['movie_users_id'];
		} elseif 
			((isset($_POST['movie_users_id'])) && (is_numeric($_POST['movie_users_id']))){
				$movie_users_id = $_POST['movie_users_id']; 
				} else {
					header("Refresh: 3;URL=current_users.php");
					echo "This page has been accessed in error. Redirecting you to the previous page";
					}

require_once('mysql_connect');

if($_POST['sure'] == 'Yes') {
	$query = "delete from movie_users where movie_users_id = $movie_users_id";
	$result = @mysql_query($query);
		}
	$query = "select concat(last_name, ',' first_name) from movie_users where movie_users_id = $movie_users_id";
	$result = @mysql_query($query);
		if (mysql_num_rows($result) == 1) {
		$row = mysql_fetch_array($result, MYSQL_NUM);
	
	?>
	<body>
	<form action="delete_user.php" method ="post">

	<div id="main">
	<p>Are you sure you want to delet this user?<br />
	<input type = "radio" name = "sure" value = "Yes" /> Yes
	<input type = "radio" name = "sure" value = "No" /> No</p>
	<p><input type = "submit" name = "submit" value = "Submit" /> </p>
	<input type = "hidden" name = "submitted" value = "TRUE" />
	<input type = "hidden" name = "movie_users_id" value = "' . $movie_users_id . '" />
	</form>
	</body>
	</div>
	 
mysql_close();
<?php
include('footer.php');

?>

Where is the closing bracket for this last if statement?

if (mysql_num_rows($result) == 1) {
		$row = mysql_fetch_array($result, MYSQL_NUM);
	
	?>
	<body>
	<form action="delete_user.php" method ="post">

	<div id="main">
	<p>Are you sure you want to delet this user?<br />
	<input type = "radio" name = "sure" value = "Yes" /> Yes
	<input type = "radio" name = "sure" value = "No" /> No</p>
	<p><input type = "submit" name = "submit" value = "Submit" /> </p>
	<input type = "hidden" name = "submitted" value = "TRUE" />
	<input type = "hidden" name = "movie_users_id" value = "' . $movie_users_id . '" />
	</form>
	</body>
	</div>
	 
mysql_close();
<?php
include('footer.php');

?>

Oh that helped tremendously! I can't believe I missed that! Thank you.

To Robothy:

Thank you for finding that missing curly brace. I had been looking for a long time, and I guess I just missed it in Notepad ++.

However, I now have a new problem. When I click "Yes" to delete the user, the user never gets deleted. I ran the exact same query in the regular MySQL database and it worked. Something else I'm missing?

<?php
session_start();
include('header.php');


	if((isset($_GET['id'])) && (is_numeric($_GET['id']))) {
		$id = $_GET['id'];
		} elseif 
			(isset($_POST['id'])){
				$id = $_POST['id']; 
				} else {
					header("Refresh: 60;URL=current_users.php");
					echo "This page has been accessed in error. Redirecting you to the previous page".mysql_error();
					}

require_once('mysql_connect.php');
if(isset($_POST['submitted'])){
if($_POST['sure'] == 'Yes') {
	$query = "delete from movie_users where movie_users_id = $id";
	$result = @mysql_query($query);
		
			header("Refresh: 3;URL=current_users.php");
					echo "User deleted successfully";
	}
		
	$query = "select concat(last_name, ',' first_name) from movie_users where movie_users_id = $id";
	$result = @mysql_query($query);
		if (mysql_num_rows($result) == 1) {
		$row = mysql_fetch_array($result, MYSQL_NUM);
	}
	}
		
	?>
	<body>
	<form action="delete_user.php" method ="post">
	<div id="main">
		
		<p>Are you sure you want to delete this user?<br />
	<input type = "radio" name = "sure" value = "Yes" /> Yes
	<input type = "radio" name = "sure" value = "No" /> No</p>
	<p><input type = "submit" name = "submit" value = "Submit" /> </p>
	<input type = "hidden" name = "submitted" value = "TRUE" />
	<input type = "hidden" name = "id" value = "' . $id . '" />
	</form>
	</body>
	</div>
	 
mysql_close();
<?php
include('footer.php');

?>

Try printing out your query and dying the script before you actually run the query, cos it looks like your variable $id is out of scope.

Easy fix for that would be to preset it to 0 at the top of your script, $id = 0;

Cheers,
R

Hi,

Why is mysql_close();

outside of <??>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.