teddy777 Posted March 24, 2009 Share Posted March 24, 2009 I get this error when checking my syntax, common causes seem to be missing a semi colon from the code, causing it to try and parse the line after the last line of the file or misspelling a variable. I'm not sure so, does any body know how to fix this. <?php // Connect to server and select databse. ; mysql_select_db('---')or die('cannot select DB'); $myusername=$_POST['myusername']; $password1=$_POST['password1']; $password2=$_POST['password2']; $myemailaddress=$_POST['email']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername'"; $result=mysql_query($sql); if($_POST['submit']){ //username checking if($myusername && strlen($myusername) >= 3){ $query = mysql_query("SELECT `id` FROM `regtut` WHERE `username`='". $myusername."' LIMIT 1"); if(mysql_num_rows($query)){ $error['userexists'] = 'Username exists'; } } else { $error['usernameinput'] = 'Please enter a username of 3+ characters'; } //email checking if($myemailaddress){ if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $myemailaddress)){ $error['emailerror'] = 'Email Incorrect'; } } else { $error['emailinput'] = 'Please supply an email address'; } //Password checking if($password1 && $password2){ if($password1 != $password2){ $error['passmismatch'] = 'Passwords don\'t match'; } } else { $error['passwordinput'] = 'Please enter your password in both fields'; } } if(!$error && $_POST['submit']){ $sql = mysql_query("INSERT INTO `regtut` (username, password, email) VALUES ('".$myusername."', '".md5($password1)."', '".$myemailaddress."')"); if($query){ echo $myusername .' is now registered'; } ?> this is my code its my first ever attempt at php an a login code so its a bit cobbled together. Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/ Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 Line number the error is on??? Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793068 Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 What line number is reported? Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793069 Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 The bracket is not closed for if(!$error && $_POST['submit']){ line 51 Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793072 Share on other sites More sharing options...
teddy777 Posted March 24, 2009 Author Share Posted March 24, 2009 thanks that worked, sorry it was such a trivial error Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793077 Share on other sites More sharing options...
Mchl Posted March 24, 2009 Share Posted March 24, 2009 Get yourself some good IDE I pasted your code into NetBeans and it marked the error right away. Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793079 Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 I agree - I use both Notepad++ and EditPlus. Link to comment https://forums.phpfreaks.com/topic/150956-solved-parse-error-parse-error-unexpected/#findComment-793084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.