943,910 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1514
  • PHP RSS
Apr 17th, 2009
0

Parse error: syntax error, unexpected $end

Expand Post »
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 Syntax (Toggle Plain Text)
  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. ?>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 17th, 2009
0

Re: Parse error: syntax error, unexpected $end

Where is the closing bracket for this last if statement?


PHP Syntax (Toggle Plain Text)
  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 blocblue; Apr 17th, 2009 at 10:25 am.
Reputation Points: 101
Solved Threads: 74
Posting Pro in Training
blocblue is offline Offline
430 posts
since Jan 2008
Apr 17th, 2009
0

Re: Parse error: syntax error, unexpected $end

Oh that helped tremendously! I can't believe I missed that! Thank you.
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 17th, 2009
0

Re: Parse error: syntax error, unexpected $end

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 Syntax (Toggle Plain Text)
  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. ?>
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 17th, 2009
0

Re: Parse error: syntax error, unexpected $end

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
Reputation Points: 101
Solved Threads: 74
Posting Pro in Training
blocblue is offline Offline
430 posts
since Jan 2008
Apr 18th, 2009
0

Re: Parse error: syntax error, unexpected $end

Hi,

Why is mysql_close();

outside of <??>
Reputation Points: 28
Solved Threads: 19
Junior Poster
vicky_rawat is offline Offline
137 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Multiple values in one cookie
Next Thread in PHP Forum Timeline: posting a multiple select form object





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC