编码错误解析错误:语法错误,C:\ xampp \ htdocs \ test \ submit.php中意外的'$ username'(T_VARIABLE)

时间:2017-09-20 16:26:14

标签: php mysql mysqli

<?php
$x=$_POST[ 'firstname'];
$y=$_POST[ 'lastname'];
$servername = "localhost"
$username = "root";
$password = "";
$dbname="dbl";

我一直在第24行的C:\ xampp \ htdocs \ test \ submit.php中收到错误Parse错误:语法错误,意外的'$ username'(T_VARIABLE) 任何人都可以帮忙

完整代码:

<head>
<style>
table {
    font-family: Arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

td, th {
    Border: lpc solid #dddddd
    text-align: left;
    padding: 8px
}

tr:nth-child(even) {
    background-color: #dddddd
}
</style>
</head>
<?php
$x=$_POST[ 'firstname'];
$y=$_POST[ 'lastname'];
$servername = "localhost"
$username = "root";
$password = "";
$dbname="dbl";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn-> connection_error) {
    die("connection failed: " . $conn->connection_error);
}
echo "connected successfully";
$sql = "INSERT INTO 'user' ('fname', 'lname') VALUES ('$x' , Sy')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "error: " .  $sql . "<br>" . $conn->error;
}
$sql = "select id, fname, lname FROM user";
$result =
$conn->close () ;
?>

0 个答案:

没有答案