Login code help, Parse error: syntax error, unexpected T_STRING in C:\xampp\htdo

I have been thinking about this error for two days now I cant sleep I cant eat , AAAAAH why? help meee!! please!!!

(Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\JAck\Login_reg.php on line 172)

[php]<?php
/*Program: Login_reg.php
*Desc: Main application script for user login
*This application provides two options:
*(1)Login using existing username and
*(2)Register a new user
*/

Session_Start();
switch(@$_POST[‘button’])
{
Case " Log in":
Include(“dogs.inc”);
$cxn =mysqli_connect($host,$user,$password,$database)
or die (“Could not connect to database”);
$sql = “SELECT loginName from member
where loginName = ‘$_POST [fusername]’”;
$result = mysqli_query ($cxn,$sql)
or die (“Query died: fusername”);
$num = mysqli_num_rows($result);
if ($num > 0) // LOGIN NAME WAS FOUND
{
$sql = “SELECT loginName FROM member
where loginName =’$_POST[fusername]’
AND password = md5(’$_POST[fpassword]’)”;
$result2 = mysqli_query($cxn,$sql)
or die (“qquery died: fpassword”);
$num2 = mysqli_num_rows($result2);
if($num2 > 0) // password matchess
{
$_SESSION[‘auth’] =“yes”;
$_SESSION[‘logName’] = $_POST [‘fusername’];
$sql = “INSERT INTO Login (loginName,LoginTime)
VALUES(’$_SESSION[logname]’,NOW())”;
$result = mysqli_query($cxn,$sql)
or die (“query died: insert”);
header(“location: SecretPage.php”);

}
else
{
$message_1 =“the login name,’$_POST[fusername]’ already exists”;
$fusername = strip_tags(trim($_POST[‘fusername’]));
include(“login_form.inc”);
}
}
else //login name not found
{
$message_1 =“The user Name you have entered does not exist! Please try again.”;
include (“login_form.inc”);
}
break;

Case “Register”:
/*Check for blanks /
foreach ($_POST as $field => $value)
{
if ($field != “fax”)
{
if (empty($value))
{
$blanks[] = $field;
}
else
{
$good_data[$field] = strip_tags(trim($value));
}
}
}
if(isset($blanks))
{
$message_2 = “THE FOLLOWING FIELDS ARE BLANK.”;
foreach($blank as $value)
{
$message_2 .="value, ";
}
extract ($good_data);
include (“login_form.inc”);
exit();
}
/
Validate Data */
foreach($_POST as $field => $value)
{
if (!empty($value))
{
if(preg_match("/name/i",$field)and
!preg_match("/user/i",$field)and
!preg_match("/log/i",$field))
{
if (!preg_match("/^[A-za-z’ -]{1,50}$/",$value))
{
$errors[] = “$value is not a valid name.”;
}
}
if(preg_match("/street/i",$field)or
preg_match("/addr/i",$field)or
preg_match("/city/i",$field))
{
if(!preg_match("/ ^ [A-Za-z0-9.,’ -]{1.50}$/", $value))
{
$errors[] = “$value is not a valid address or city.”;
}
}
if(preg_match("/state/i",$field))
{
if(!preg_match("/^[A-Z][A-Z]$/",$value))
{
$errors[] = “$value is not valid state code.”;
}
}
if(preg_match("/email/i",$field))
{
if(!preg_match("/^.+@.+\. . +$/",value))
{
$errors[] = “$value is not a valid email addr.”;
}
}
if (preg_match("/zip/i",$field))
{
if(!preg_match("/^[0-9]{5}(-[0-9]{4})?$/",
$value))
{
$errors[] = “$value is not a valid zipcode.”;
}
}
if(preg_match("/phone/i",$field )or
preg_match("/fax/i",$field))
{
if ( !preg_match("/^[0-9)(xX -]{7,20}$/",$value))
{

$errors[] = “$value is not a valid phone no.”;

}
}
}
}//End if not empty
Foreach($_POST as $field => $value)
{
$$filed = strip_tags(trim($value));
}
if(@is_array($errors))
{
$message_2 = “”;
foreach($errors as $value)
{
$message_2 .= $value.“please try again
”;
}
Include(“login_form.inc”);
exit();
} //End if errors aare found

/Check to see if username already exists/
include(“dogs.inc”);
$cxn = mysqli_connect($host,$user,$password,$database)
or die (“couldnt connect to database”);
$sql = “SELECT loginName FROM Member
WHERE LoginName = ‘$loginName’”;
$result = mysqli_query($cxn,$sql)
or die(“Query died: loginName.”);
$num = mysqli_num_rows($result);
if ($num > 0)
{
$message_2 = “$loginName already used. Select anouther user Nanme.”;
include("login_form.inc);
exit();
}//end if username exists

else //add new member
{
$sql=“INSERT INTO Member (loginName,CreateDate,password,lastname,firstname,street,city,state,ZIP,Email,phone,fax)VALUES
(’$loginName’,NOW(),md5(’$password’),’$lastName’,’$firstName’,’$street’,’$city’,’$state’,’$ZIP’,’$email’,’$phone’,’$fax’)”;

mysqli_query($cxn,$sql);
$_SESSION[‘auth’]=“yes”;
$_SESSION[‘logname’] = $loginName;
/send email to new Custome/
$emess= “You have succesfullymregistered”;
$emess .= “user name and passwords are.”;
$emess .="\n\n\t$loginName\n\t";
$emess .="$password\n\n";
$emess .= “we appreciate your interest. \n\n”;
$emess .= “If you have any questions or problems,”;
$emess .= “email me”;

$mailsend = mail("$email","$subj","$emess");

header(“location: SecretPage.php”);
}
break;
default:
include (“login_form.inc”);
}
?>[/php]

This is line 172

[php]$sql=“INSERT INTO Member (loginName,CreateDate,password,lastname,firstname,street,city,state,ZIP,Email,phone,fax)VALUES
(’$loginName’,NOW(),md5(’$password’),’$lastName’,’$firstName’,’$street’,’$city’,’$state’,’$ZIP’,’$email’,’$phone’,’$fax’)”;
[/php]

That line number doesn’t represent where the actual error is, its usually a few lines above it. This isn’t the error, but is there supposed to be 2 $$ in $$filed = strip_tags(trim($value));?

this might be the problem - include("login_form.inc); should be include(“login_form.inc”);

in forums, stuff in php tags are usually color coded, and in this case, everything below the line above is red, indicating something is wrong :slight_smile:

if you remove the bold [ b ] [ /b ] tag from this line does that fix it?

[php]$sql=“INSERT INTO Member (loginName,CreateDate,password,lastname,firstname,street,city,state,ZIP,Email,phone,fax)VALUES
(’$loginName’,NOW(),md5(’$password’),’$lastName’,’$firstName’,’$street’,’$city’,’$state’,’$ZIP’,’$email’,’$phone’,’$fax’)”;[/php]

and line 166
[php] include("login_form.inc); [/php]
should be
[php]include(“login_form.inc”);[/php]

the bold tags are there because it doesn’t get parsed inside of the php bbcode tags.

Sponsor our Newsletter | Privacy Policy | Terms of Service