How do I fix : Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\Patient Registration\server.php on line 23 [duplicate]

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm having problem with my code on a line. An error pops up ,

Error :

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\Patient Registration\server.php on line 23.

Please help.

I have tried to delete and alter what I could but nothing happened. Line 23 is the bold'ed' };

EDITED : Thanks for those who replied but can you guys check my code again? I encountered different errors this time.

Errors :

Notice: Undefined index: username in C:\xampp\htdocs\Patient Registration\server.php on line 14

Notice: Undefined index: email in C:\xampp\htdocs\Patient Registration\server.php on line 15

Notice: Undefined index: password in C:\xampp\htdocs\Patient Registration\server.php on line 16

Notice: Undefined index: password_confirm in C:\xampp\htdocs\Patient Registration\server.php on line 17

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Patient Registration\server.php on line 36

Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in C:\xampp\htdocs\Patient Registration\errors.php on line 15



php

session_start();

//Variables declared
$username = "";
$email = "";

$errors = array();
//Connect to database
$db = mysqli_connect('localhost','root','','patient') or die("Could not connect to the database");

//Registeration area
$username = mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$re_password = mysqli_real_escape_string($db, $_POST['password_confirm']);

//Errors popup
if(empty($username) || empty($email) || empty($password))

    {
        array_push($errors, "Required field");
    }

    if($password != $re_password) 
        {
            array_push($errors, "Password must match");
        }

//Existing username check

$user_check_query = "SELECT * FROM patient WHERE Patient Name = '$username' or Patient Email = '$email' LIMIT 1";

$result = mysqli_query($db, $user_check_query);
$user = mysqli_fetch_assoc($result);

if($user)

{
    if($user['username'] === $username)

        {
            array_push($errors, "Username has already been used");
        }

    if($user['email'] === $email)

        {
            array_push($errors, "Email has already been used");
        }
}

//Successful registration

if(count($errors) == 0)

{
    $passwordhash = md5($password); //Password encryption
    $query = "INSERT INTO patient (Patient_Name, Patient_Email, Password) VALUES ('$username', '$email', '$password')";

    mysqli_query
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.