Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 29th, 2008, 6:22 PM   #1
roma2509
Newbie
 
Join Date: May 2008
Posts: 4
Rep Power: 0 roma2509 is on a distinguished road
Question php error

Hello for all. i try to write a php forum. in one of my php files when i execut him a teke a syntax error "syntax error, unexpected '}' in". can any body help me?
the cod is:
php Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3. require("config.php");
  4. require("functions.php");
  5. $db = mysql_connect($dbhost, $dbuser, $dbpassword);
  6. mysql_select_db($dbdatabase, $db);
  7. $db = mysql_connect($dbhost, $dbuser, $dbpassword);
  8. mysql_select_db($dbdatabase, $db);
  9. if($_POST['submit']) {
  10. $sql = "SELECT * FROM users WHERE username = '"
  11. . $_POST['username'] . "' AND password = '"
  12. . $_POST['password'] . "';";
  13. $result = mysql_query($sql);
  14. $numrows = mysql_num_rows($result);
  15. $result = mysql_query($sql);
  16. $numrows = mysql_num_rows($result);
  17. if($numrows == 1) {
  18. $row = mysql_fetch_assoc($result);
  19. if($row['active'] == 1) {
  20. session_register("USERNAME");
  21. session_register("USERID");
  22. $_SESSION['USERNAME'] = $row['username'];
  23. $_SESSION['USERID'] = $row['id'];
  24. switch($_GET['ref']) {
  25. case "newpost":
  26. if(isset($_GET['id']) == FALSE) {
  27. header("Location: " . $config_basedir .
  28. "/newtopic.php");
  29. } else {
  30. header("Location: " . $config_basedir .
  31. "/newtopic.php?id=" . $_GET['id']);
  32. }
  33. break;
  34. case "reply":
  35. if(isset($_GET['id']) == FALSE) {
  36. header("Location: " . $config_basedir .
  37. "/newtopic.php");
  38. } else {
  39. header("Location: " . $config_basedir .
  40. "/newtopic.php?id=" . $_GET['id']);
  41. }
  42. break;
  43. default:
  44. header("Location: " . $config_basedir);
  45. break;
  46. }
  47. }
  48. else {
  49. require("header.php");
  50. echo "This account is not verified yet. You were emailed a link
  51. to verify the account. Please click on the link in the email to
  52. continue.";
  53. }
  54. echo "This account is not verified yet. You were emailed a link
  55. to verify the account. Please click on the link in the email to
  56. continue.";
  57. }
  58. } else {
  59. header("Location: " . $config_basedir . "/login.php?error=1");
  60. }} else {
  61. require("header.php");
  62. if($_GET['error']) {
  63. echo "Incorrect login, please try again!";
  64. }
  65. ?>
  66. <form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>"
  67. method="post">
  68. <table>
  69. <tr>
  70. <td>Username</td>
  71. <td><input type="text" name="username"></td>
  72. </tr>
  73. <tr>
  74. <td>Password</td>
  75. <td><input type="password" name="password"></td>
  76. </tr>
  77. <tr>
  78. <td></td>
  79. <td><input type="submit" name="submit" value="Login!"></td>
  80. </tr>
  81. </table>
  82. </form>
  83. Don't have an account? Go and <a href="register.php">Register</a>!
  84. <?php
  85. }
  86. require("footer.php");
  87. ?>
  88.  
and the error is to line 63. the cod is write for the login of users.

Last edited by big_k105; May 30th, 2008 at 8:02 AM. Reason: formatting and code tags
roma2509 is offline   Reply With Quote
Old May 30th, 2008, 2:10 AM   #2
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
Re: php error

Here's a tip: format your code, and post it inside [code] and [/code] tags. If you have a decent coding style (i.e. easily readable; I like to use BSD/Allman style), it should be almost immediately apparent where the missing brace is.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old May 30th, 2008, 8:05 AM   #3
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,650
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Re: php error

While I was formatting your code and adding the code tags I noticed you have an extra { in the code. Take a look at what is now line 60 in the code above. It helps when the code is formatted as you can then see that all of then { } have a beginning and an end.
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP script ending prematurely causing Internal Error...??? Syntax_Error PHP 2 Feb 29th, 2008 8:42 PM
Basic Socket Programming Error in Linux.. Pls help boraciner C++ 18 Sep 12th, 2007 1:17 AM
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Masm rsnd Assembly 4 May 20th, 2006 9:05 PM
libraries matko C 1 Jan 22nd, 2006 2:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC