GroundZeroStudio Posted February 18, 2007 Share Posted February 18, 2007 I keep getting a stupid parse error and it is really annoying See the error at :http://groundzero.1111mb.com/login.php Code is as following: (note: Is not all of the code, i have to much: else { $today = date("Y-m-d"); $sql = "INSERT INTO ClientData (LoginName, CreateDate, Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES ('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone', '$fax','$email')"; mysql_quey($sql); $_SESSION['auth']="yes"; $_SESSION['logname'] = $newname; $emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish"; $emess="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your"; $emess=" user name and password"; $ehead="From groundzerostudios@gmail.com "; $subj = "Your client account with Ground Zero Studios"; $mailsend=mail("$email","$subj","$emess","ehead"); header("Location: index.php"); } break; default: (HERE IS WHERE ERROR OCCURS: { include("login_form.html"); exit(); } ?> All of my PHP editors/debuggers say there is NO errors, so I can not figure out the problem. All help is appreciated. Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted February 18, 2007 Share Posted February 18, 2007 what line is 147? Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 18, 2007 Author Share Posted February 18, 2007 The line that says default, I said in my original post that was where the error was happening. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 18, 2007 Share Posted February 18, 2007 You need to show us the entire switch statement. And please surround your code with tags. Ken Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 18, 2007 Share Posted February 18, 2007 It appears you are using a set of if/else/else's. There is no default for that, default is for switches. Just put an else without any conditions on it and it will act just like default. Quote Link to comment Share on other sites More sharing options...
nloding Posted February 18, 2007 Share Posted February 18, 2007 I also noticed that for $emess, you're not adding to the string. You just keep replacing the text each time, so that by the time it ends, $emess = " username and password". You want to be using .= not just = Otherwise, the only error I see is what someone pointed out ... default only applies to a switch statement, not an if/else series ... if you have a full switch statement, post the entire statement. Otherwise, that's your issue. Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 18, 2007 Author Share Posted February 18, 2007 <?php /* Program: Register.php * Desc: Register program for the Clients only section of Ground Zero Studios * Version: 1.00.00 */ session_start(); include("rebound.php"); switch (@$_GET['do']) { case "login"; $connection = mysql_connect($host, $user,$password) or die("Couldn't connect to a valid server."); $db = mysql_select_db($database, $connection) or die("Couldn't select a valid database"); $sql = "SELECT LoginName FROM $database WHERE LoginName='$_POST[fusername]'"; $result = mysql_query($sql) or die("Unable to execute the specified MySQL query"); $num = mysql_num_rows($result); if ($num == 1) //login name was located { $sql = "SELECT LoginName FROM $database WHERE LoginName ='$_POST[fusername]' AND Password=password('$_POST[fpassword]')"; $result2 = mysql_query($sql) or die("Unable to execute the specified MySQL query"); $num2 = mysql_num_rows($result2); if ($num2 > 0) //the correct password was entered { $_SESSION['auth']="yes"; $logname=$_POST['fusername']; $_SESSION['logname'] = $logname; $today = date("Y-m-d h:m:s"); $sql = "INSERT INTO Login (LoginName, LoginTime) VALUES ('$logname','today')"; mysql_query($sql) or die("Unable to execute the specified MySQL query"); header("Location; Member_page.php"); } else { unset($do); $message="The Login Name, '$_POST[fusername]' exists, but you have entered the incorrect password! Please try again.<br>"; include("loginform.inc"); } } elseif ($num ==0) // The login name was not located { unset($do); $message = "The Login Name you entered is not a valid Login Name. If you wish to create this login name please feel free to register it. If you have already registered please enter it again.<br>"; include("login_form.html"); } break; case "new": foreach($_POST as $field => $value) { if ($field != "fax") { unset($_GET['do']); $message_new = "A Required field entry is missing. Please try again."; include("login_form.html"); exit(); } } if (ereg("(Name)", $field)) { /*if (!ereg("^[A-Za-z' -]{1,50}$",$value)) { unset($_GET['do']); $message_new = "$field is not a valid name. Please try again."; include("login_form.html"); exit(); }*/ } $$field = strip_tags(trim($value)); } //end foreach if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip)) { unset($_get['do']); $message_new = "$zip is not a valid zip code. Please try again."; include("login_form.html"); exit(); } if (!ereg("^[0-9)(xX -]{7,20}$",$phone)) { unset($_GET['do']); $message_new = "$phone is not a valid phone number. Please try again."; include("login_form.html"); exit(); } if ($fax != "" ) { if (!ereg("^[0-9)(xX -]{7,20}$",$fax)) { unset($_GET['do']); $message_new = "$fax is not a valid fax machine number. Please try again."; include("login_form.html") ; exit(); } } if (!ereg("^.+@.+\\..+$",$email)) { unset($_GET['do']); $message_new = "$email is not a valid email address. Please re-enter it."; include("login_form.html"); exit(); } /* check to see if login name already exists in the database */ $connection =mysql_connect($host,$user,$password) or die ("Unable to connect to server"); $db = mysql_select_db($database,$connection) or die("Unable to select a valid database"); $sql = "SELECT LoginName FROM ClientData WHERE LoginName='newname'"; $result = mysql_query($sql) or die("Unable to execute specified MySQL query"); $num = mysql_numrows($result); if ($num > 0) { unset($_GET['do']); $message_new = "$newname already registered. Please select another Member ID."; include("login_form.html"); exit(); } else { $today = date("Y-m-d"); $sql = "INSERT INTO ClientData (LoginName, CreateDate, Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES ('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone', '$fax','$email')"; mysql_quey($sql); $_SESSION['auth']="yes"; $_SESSION['logname'] = $newname; $emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish"; $emess="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your"; $emess=" user name and password"; $ehead="From groundzerostudios@gmail.com "; $subj = "Your client account with Ground Zero Studios"; $mailsend=mail("$email","$subj","$emess","ehead"); header("Location: index.php"); } break; default: { include("login_form.html"); exit(); } ?> Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 18, 2007 Share Posted February 18, 2007 Oh, so it was part of a switch. Really easy then: you don't put cases in curly braces. So for your default clause: default: //No curly braces, just like a regular case include("login_form.html"); exit(); break; //End with break; just like a regular case } //Close the switch Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 18, 2007 Share Posted February 18, 2007 On you first "case" statement, you have a semi-colon at the end instead of a colon. That might be confusing PHP. Ken Quote Link to comment Share on other sites More sharing options...
printf Posted February 18, 2007 Share Posted February 18, 2007 Remove... default: { // <- this And change this... case "login"; to this... case "login": printf Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 18, 2007 Author Share Posted February 18, 2007 STILL WONT WORK!!!! Annoying me now. :'( <?php /* Program: Register.php * Desc: Register program for the Clients only section of Ground Zero Studios * Version: 1.00.00 */ session_start(); include("rebound.php"); switch (@$_GET['do']) { case "login": $connection = mysql_connect($host, $user,$password) or die("Couldn't connect to a valid server."); $db = mysql_select_db($database, $connection) or die("Couldn't select a valid database"); $sql = "SELECT LoginName FROM $database WHERE LoginName='$_POST[fusername]'"; $result = mysql_query($sql) or die("Unable to execute the specified MySQL query"); $num = mysql_num_rows($result); if ($num == 1) //login name was located { $sql = "SELECT LoginName FROM $database WHERE LoginName ='$_POST[fusername]' AND Password=password('$_POST[fpassword]')"; $result2 = mysql_query($sql) or die("Unable to execute the specified MySQL query"); $num2 = mysql_num_rows($result2); if ($num2 > 0) //the correct password was entered { $_SESSION['auth']="yes"; $logname=$_POST['fusername']; $_SESSION['logname'] = $logname; $today = date("Y-m-d h:m:s"); $sql = "INSERT INTO Login (LoginName, LoginTime) VALUES ('$logname','today')"; mysql_query($sql) or die("Unable to execute the specified MySQL query"); header("Location; Member_page.php"); } else { unset($do); $message="The Login Name, '$_POST[fusername]' exists, but you have entered the incorrect password! Please try again.<br>"; include("loginform.inc"); } } elseif ($num ==0) // The login name was not located { unset($do); $message = "The Login Name you entered is not a valid Login Name. If you wish to create this login name please feel free to register it. If you have already registered please enter it again.<br>"; include("login_form.html"); } break; case "new": foreach($_POST as $field => $value) { if ($field != "fax") { unset($_GET['do']); $message_new = "A Required field entry is missing. Please try again."; include("login_form.html"); exit(); } } if (ereg("(Name)", $field)) { /*if (!ereg("^[A-Za-z' -]{1,50}$",$value)) { unset($_GET['do']); $message_new = "$field is not a valid name. Please try again."; include("login_form.html"); exit(); }*/ } $$field = strip_tags(trim($value)); } //end foreach if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip)) { unset($_get['do']); $message_new = "$zip is not a valid zip code. Please try again."; include("login_form.html"); exit(); } if (!ereg("^[0-9)(xX -]{7,20}$",$phone)) { unset($_GET['do']); $message_new = "$phone is not a valid phone number. Please try again."; include("login_form.html"); exit(); } if ($fax != "" ) { if (!ereg("^[0-9)(xX -]{7,20}$",$fax)) { unset($_GET['do']); $message_new = "$fax is not a valid fax machine number. Please try again."; include("login_form.html") ; exit(); } } if (!ereg("^.+@.+\\..+$",$email)) { unset($_GET['do']); $message_new = "$email is not a valid email address. Please re-enter it."; include("login_form.html"); exit(); } /* check to see if login name already exists in the database */ $connection =mysql_connect($host,$user,$password) or die ("Unable to connect to server"); $db = mysql_select_db($database,$connection) or die("Unable to select a valid database"); $sql = "SELECT LoginName FROM ClientData WHERE LoginName='newname'"; $result = mysql_query($sql) or die("Unable to execute specified MySQL query"); $num = mysql_numrows($result); if ($num > 0) { unset($_GET['do']); $message_new = "$newname already registered. Please select another Member ID."; include("login_form.html"); exit(); } else { $today = date("Y-m-d"); $sql = "INSERT INTO ClientData (LoginName, CreateDate, Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES ('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone', '$fax','$email')"; mysql_quey($sql); $_SESSION['auth']="yes"; $_SESSION['logname'] = $newname; $emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish"; $emess.="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your"; $emess.=" user name and password"; $ehead="From groundzerostudios@gmail.com "; $subj = "Your client account with Ground Zero Studios"; $mailsend=mail("$email","$subj","$emess","ehead"); header("Location: index.php"); } break; default: include("login_form.html"); } ?> Still parse error, unexpected T_DEFAULT Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 18, 2007 Share Posted February 18, 2007 You have a comment that says "end foreach". That end bracket is not the end of the foreach. The foreach was ended by a end bracket a few lines before, so PHP is taking that end bracket as the end of the switch statement and that causes the error later. Ken Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 19, 2007 Author Share Posted February 19, 2007 ok, so how do i fix it? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 19, 2007 Share Posted February 19, 2007 Figure out where the foreach is supposed to end and put the bracket in the correct place (or just remove that bracket and see if the code works). Ken Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 19, 2007 Author Share Posted February 19, 2007 YEAH!! FIXED!! thanks a lot, I could not of done it without your guys help, I really appreciate it Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 19, 2007 Author Share Posted February 19, 2007 Some stupid NOOB used my rebound.php script to access my database and made 68 tables. THEY ARE ALL GETTING DELETED!!! something to do with CDB, I think they are forums. If you are stealing my SQL database you are such a noob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.