Parse error: syntax error, unexpected $end

Reply

Join Date: Oct 2008
Posts: 42
Reputation: JimD C++ Newb is an unknown quantity at this point 
Solved Threads: 0
JimD C++ Newb JimD C++ Newb is offline Offline
Light Poster

Parse error: syntax error, unexpected $end

 
0
  #1
Apr 17th, 2009
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

  1. <?php
  2. session_start();
  3. include('header.php');
  4.  
  5.  
  6. if((isset($_GET['movie_users_id'])) && (is_numeric($_GET['movie_users_id']))) {
  7. $movie_users_id = $_GET['movie_users_id'];
  8. } elseif
  9. ((isset($_POST['movie_users_id'])) && (is_numeric($_POST['movie_users_id']))){
  10. $movie_users_id = $_POST['movie_users_id'];
  11. } else {
  12. header("Refresh: 3;URL=current_users.php");
  13. echo "This page has been accessed in error. Redirecting you to the previous page";
  14. }
  15.  
  16. require_once('mysql_connect');
  17.  
  18. if($_POST['sure'] == 'Yes') {
  19. $query = "delete from movie_users where movie_users_id = $movie_users_id";
  20. $result = @mysql_query($query);
  21. }
  22. $query = "select concat(last_name, ',' first_name) from movie_users where movie_users_id = $movie_users_id";
  23. $result = @mysql_query($query);
  24. if (mysql_num_rows($result) == 1) {
  25. $row = mysql_fetch_array($result, MYSQL_NUM);
  26.  
  27. ?>
  28. <body>
  29. <form action="delete_user.php" method ="post">
  30.  
  31. <div id="main">
  32. <p>Are you sure you want to delet this user?<br />
  33. <input type = "radio" name = "sure" value = "Yes" /> Yes
  34. <input type = "radio" name = "sure" value = "No" /> No</p>
  35. <p><input type = "submit" name = "submit" value = "Submit" /> </p>
  36. <input type = "hidden" name = "submitted" value = "TRUE" />
  37. <input type = "hidden" name = "movie_users_id" value = "' . $movie_users_id . '" />
  38. </form>
  39. </body>
  40. </div>
  41.  
  42. mysql_close();
  43. <?php
  44. include('footer.php');
  45.  
  46. ?>
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 141
Reputation: robothy is an unknown quantity at this point 
Solved Threads: 19
robothy robothy is offline Offline
Junior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #2
Apr 17th, 2009
Where is the closing bracket for this last if statement?

Originally Posted by JimD C++ Newb View Post

  1. if (mysql_num_rows($result) == 1) {
  2. $row = mysql_fetch_array($result, MYSQL_NUM);
  3.  
  4. ?>
  5. <body>
  6. <form action="delete_user.php" method ="post">
  7.  
  8. <div id="main">
  9. <p>Are you sure you want to delet this user?<br />
  10. <input type = "radio" name = "sure" value = "Yes" /> Yes
  11. <input type = "radio" name = "sure" value = "No" /> No</p>
  12. <p><input type = "submit" name = "submit" value = "Submit" /> </p>
  13. <input type = "hidden" name = "submitted" value = "TRUE" />
  14. <input type = "hidden" name = "movie_users_id" value = "' . $movie_users_id . '" />
  15. </form>
  16. </body>
  17. </div>
  18.  
  19. mysql_close();
  20. <?php
  21. include('footer.php');
  22.  
  23. ?>
Last edited by robothy; Apr 17th, 2009 at 10:25 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: JimD C++ Newb is an unknown quantity at this point 
Solved Threads: 0
JimD C++ Newb JimD C++ Newb is offline Offline
Light Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #3
Apr 17th, 2009
Oh that helped tremendously! I can't believe I missed that! Thank you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: JimD C++ Newb is an unknown quantity at this point 
Solved Threads: 0
JimD C++ Newb JimD C++ Newb is offline Offline
Light Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #4
Apr 17th, 2009
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?

  1. <?php
  2. session_start();
  3. include('header.php');
  4.  
  5.  
  6. if((isset($_GET['id'])) && (is_numeric($_GET['id']))) {
  7. $id = $_GET['id'];
  8. } elseif
  9. (isset($_POST['id'])){
  10. $id = $_POST['id'];
  11. } else {
  12. header("Refresh: 60;URL=current_users.php");
  13. echo "This page has been accessed in error. Redirecting you to the previous page".mysql_error();
  14. }
  15.  
  16. require_once('mysql_connect.php');
  17. if(isset($_POST['submitted'])){
  18. if($_POST['sure'] == 'Yes') {
  19. $query = "delete from movie_users where movie_users_id = $id";
  20. $result = @mysql_query($query);
  21.  
  22. header("Refresh: 3;URL=current_users.php");
  23. echo "User deleted successfully";
  24. }
  25.  
  26. $query = "select concat(last_name, ',' first_name) from movie_users where movie_users_id = $id";
  27. $result = @mysql_query($query);
  28. if (mysql_num_rows($result) == 1) {
  29. $row = mysql_fetch_array($result, MYSQL_NUM);
  30. }
  31. }
  32.  
  33. ?>
  34. <body>
  35. <form action="delete_user.php" method ="post">
  36. <div id="main">
  37.  
  38. <p>Are you sure you want to delete this user?<br />
  39. <input type = "radio" name = "sure" value = "Yes" /> Yes
  40. <input type = "radio" name = "sure" value = "No" /> No</p>
  41. <p><input type = "submit" name = "submit" value = "Submit" /> </p>
  42. <input type = "hidden" name = "submitted" value = "TRUE" />
  43. <input type = "hidden" name = "id" value = "' . $id . '" />
  44. </form>
  45. </body>
  46. </div>
  47.  
  48. mysql_close();
  49. <?php
  50. include('footer.php');
  51.  
  52. ?>
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 141
Reputation: robothy is an unknown quantity at this point 
Solved Threads: 19
robothy robothy is offline Offline
Junior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #5
Apr 17th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Parse error: syntax error, unexpected $end

 
0
  #6
Apr 18th, 2009
Hi,

Why is mysql_close();

outside of <??>
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC