有谁知道这两个php文件有什么问题。
我两个都得到同样的错误?
解析错误:语法错误,第2行/home/a1051468/public_html/register.php中的意外T_STRING
<?php
$con = mysqli_connect('mysql7.000webhost.com', 'a1051468_oliver', 'password', 'a1051468_RegApp');
$name = $_POST['name'];
$age = $_POST['age'];
$password = $_POST['password'];
$username = $_POST['username'];
$statement = mysqli_prepare($con, 'INSERT INTO User (name, age, username, password) VALUES (?, ? ?, ?) ');
mysqli_stmt_bind_param($statement, 'siss', $name, $age, $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
mysqli_close($con);
?>
解析错误:语法错误,第2行/home/a1051468/public_html/FetchUserData.php中的意外T_STRING
<?php
$con = mysqli_connect("mysql7.000webhost.com", "a1051468_oliver", "password", "a1051468 _RegApp");
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM User WHERE username = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $userID, $name, $age, $username, $password);
$user = array();
while(mysqli_stmt_fetch($statement)){
$user["name"] = $name;
$user["age"] = $age;
$user["username"] = $username;
$user["password"] = $password;
}
echo json_encode($user);
mysqli_close($con);
?>
答案 0 :(得分:0)
错误不在它显示的行中。它必须来自此行前面的php命令。在您的情况下,它必须来自文件中的前一行,其中包含此“FetchUserData.php”
E-g
<?php
$a = "test
?>
<?php
$con=mysqli_connect('mysql7.000webhost.com','a1051468_oliver','password','a1051468_RegApp');
当我重新启动此代码时,错误位于第一行。但它显示错误如下
Line : 7, Error type : 4
Message : syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)