The full error is:

Parse error: syntax error, unexpected T_STRING in .../cgi-bin/register_login.php on line 33

The code is set to check if an email exists in the MySQL database.

If the email does exist, then it checks the password and if both agree loads the users account into an array.

If the email does not exist, then it updates the database with the email address and password inputted.

The code follows below:

<?php

/*COPYING VARIABLES FROM LOGIN FORM INTO PHP TO CHECK TO DATABASE*/

$email=$_POST["email"];
$password=$_POST["password"];


/*OPEN THE DATABASE*/

$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


/*CHECK FOR EMAIL ADDRESS IN WEBBASE DATABASE*/

$fields = mysql_list_fields("my_db","accounts");

$columns = mysql_num_fields($fields);
        
for ($i = 0; $i < $columns; $i++) 
{
    $field_array[] = mysql_field_name($fields, $i);
}
        
if (in_array($email,$field_array))
{
/*ACCOUNT EXISTS SO LOG THE USER IN...*/

$passwordcheck= "SELECT * FROM "accounts" WHERE (("email" = "$email") AND ("password" = "$password"))";

	if (mysql_qery($passwordcheck,$con))
	{

	/*INSERT THE EDIT SCRIPT HERE*/
	
	$profile = mysql_fetch_array($passwordcheck);

	}
	else
	{
	echo "Incorrect password.  Please try again.";
	}
}
else
{

/*...OR CREATE A NEW ACCOUNT IF THE ACCOUNT DOES NOT EXIST*/

$adduser= "INSERT INTO "accounts" ("email", "password") VALUES ("$email", "$password"));
mysql_query($adduser);

}


$get_id= "SELECT idnum FROM accounts WHERE (("email" = "$email") AND ("password" = "$password"))";
$idnum=mysql_query($get_id);


/*CLOSE THE DATABASE*/

mysql_close($con);

?>

...so what's wrong...? This might be a newbie question, but I only started learning LAMP a month or so ago...

Any help would be appreciated!

"SELECT * FROM "accounts" WHERE (("email" = "$email") AND ("password" = "$password"))";

You're nesting strings the wrong way. Try this instead:

"SELECT * FROM 'accounts' WHERE ((email = '$email') AND (password = '$password'))";

Here it is man hopefully fixed but remember...

1. When you call for a column its ` key not ' . (Its the key right below ESC, i don't remember the character name)

2. When calling static data it's ' (single quote)

3. table names don't have to be quoted.

4. if you use " double quotes, using double quotes again will finish your "sentence".

5. Use . (period) when inserting a variable to a "sentence"

More importantly just examine the code below where you had the errors. Using a PHP editor program will also give you different colors telling you you just broke the sentence so I suggest you get one.

<?php

/*COPYING VARIABLES FROM LOGIN FORM INTO PHP TO CHECK TO DATABASE*/

$email=$_POST["email"];
$password=$_POST["password"];


/*OPEN THE DATABASE*/

$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}


/*CHECK FOR EMAIL ADDRESS IN WEBBASE DATABASE*/

$fields = mysql_list_fields("my_db","accounts");

$columns = mysql_num_fields($fields);

for ($i = 0; $i < $columns; $i++)
{
$field_array[] = mysql_field_name($fields, $i);
}

if (in_array($email,$field_array))
{
/*ACCOUNT EXISTS SO LOG THE USER IN...*/

$passwordcheck= "SELECT * FROM accounts WHERE `email` = '".$email."' AND `password` = '".$password."'";

if (mysql_qery($passwordcheck,$con))
{

/*INSERT THE EDIT SCRIPT HERE*/

$profile = mysql_fetch_array($passwordcheck);

}
else
{
echo "Incorrect password. Please try again.";
}
}
else
{

/*...OR CREATE A NEW ACCOUNT IF THE ACCOUNT DOES NOT EXIST*/

$adduser= "INSERT INTO accounts (`email`, `password`) VALUES ('".$email."', '".$password."')";
mysql_query($adduser);

}


$get_id= "SELECT idnum FROM accounts WHERE `email` = '".$email."' AND `password` = '".$password."'";
$idnum = mysql_query($get_id);

/*CLOSE THE DATABASE*/

mysql_close($con);

?>

Thanks for all the help guys...I will go implement this the first chance I get!

Thanks again!

This question has already been answered. Start a new discussion instead.