PDA

View Full Version : Its me again! Another PHP question :P



Jon W
01-06-2008, 10:33 AM
Well, I've looked and looked and check and doubled check. And me being a noob at PHP, I just don't know what else to really look for. I keep on getting a error being:'Parse error: syntax error, unexpected $end in'. So heres my script:




<?php

$_SERVER['REMOTE_ADDR'];

//Find out if the user name is being used or not

if(isset($_POST['submit']))

{

include("db.php");

$query = mysql_query("SELECT fname FROM register WHERE fname='{$_POST['fname']}'") or die('Database error: '.mysql_error());

$num_rows = mysql_num_rows($query);

if($num_rows >0)

{

$usertaken = 'Sorry, this user name is already being used';

}
else

{

echo '';

}

// Find out if the input fields are filled in and find out if the password matchs.


include("db.php"); // connect to database

if(isset($_POST['submit']))

{

if(empty($_POST['Username']))
{
$msg1 = 'Please fill in your User name';
}
else if(empty($_POST['Password']))
{
$msg2 = 'Please fill in your password, and then retype it.';
}
else if($_POST['Password'] != $_POST['Comfirmed_password'])
{
$passMatch = 'Your Passwords do not match. Please retype them again';
}
else if(empty($_POST['Firstname']))
{
$msg3 = 'Please fill in your first name';
}
else if(empty($_POST['Lastname']))
{
$msg4 = 'Please fill in your Last Name';
}
}

else {

//Everything checked out ok, so insert into the database time.

$query = mysql_query("INSERT INTO register(`IP`, `Username`, `Password`, `Email`, `Firstname`, `Lastname`) VALUES('".$_POST['IP']."', '".mysql_real_escape_string($_POST['Username'])."', '".mysql_real_escape_string(md5($_POST['Password']))."', '".mysql_real_escape_string($_POST['Email'])."', '".mysql_real_escape_string($_POST['Firstname'])."', '".mysql_real_escape_string($_POST['Lastname'])."')") or die('Database error: '.mysql_error());


}

?>




Thanks a ton for helping me out guys. You guys have been wonderful.

Thanks again
Jon W

Inigoesdr
01-06-2008, 10:41 AM
You're missing a closing brace to your initial if switch. But more importantly you have an if/else inside of another with the same condition, which makes no sense. And you're including db.php twice for no apparent reason.