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.