我編程的網站註冊時遇到與MySQL數據庫的麻煩mysqli的連接,現在我得到這個錯誤:解析錯誤:語法錯誤,在PHP文件意外結束,與
Parse error: syntax error, unexpected end of file in /home/*****/public_html/register.php on line 50
我沒有看到我自己的錯誤,並會很高興,如果你有人可以在我的代碼找到它:
<?php
$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 . "<br>" . $conn->error;
}
//header('Location: index.php');
}
else
{
header('Location: 404.html');
}
}
if(isset ($_POST['submit']))
{
register();
}
$conn->close();
?>
現在我得到的錯誤: 電話線31非對象的成員函數查詢(),但我不知道爲什麼 –