Tuesday, 24 April 2018

mysql - Parse error: syntax error, unexpected end of file in php, with mysqli connection




I am programming a registration for a website and am having trouble with the mysql database, now i got this error:





Parse error: syntax error, unexpected end of file in /home/*****/public_html/register.php on line 50




I dont see my own mistake and would be happy if someone of you could find it in my code:






$servername = "*****";
$username = "*****";
$password = "*****";
$dbname = "*****";

$conn = mysqli_connect($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);


/*define('DB_HOST', 'mysql.hostinger.de');
define('DB_NAME', 'u544596746_cobra');
define('DB_USER','u544596746_admin');
define('DB_PASSWORD','H6huA7qFRk2v');


$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());*/

function register()

{

session_start();
if($_POST["email"]!="" and $_POST["password"]!="" and $_POST["username"]!="" and $_POST["password"]== $_POST["password_confirm"])
{
$sql = "INSERT INTO `tblUser`(`UserName`, `Vorname`, `Nachname`, `EMail`, `Geschlecht`, `Geburtsdatum`, `RegestrierungDate`, `Password`, `FKRole`) VALUES ('" .$_POST['username']. "','" . $_POST['vorname']. "','" .$_POST['nachname']. "','" .$_POST['email']. "','" .$_POST['geschlecht']. "','" .$_POST['geburtsdatum']. "',Curdate(),'" .$_POST['password']. "',2)";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {

echo "Error: " . $sql . "
" . $conn->error;
}

//header('Location: index.php');
}
else
{
header('Location: 404.html');
}
}

if(isset ($_POST['submit']))
{
register();
}
$conn->close();
?>

Answer



The line




if ($conn->connect_error) {


doesn't have a corresponding closing brace.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...