-1

Does anyone know what is wrong with these two php files.

I am getting the same error on both?

Parse error: syntax error, unexpected T_STRING in /home/a1051468/public_html/register.php on line 2

<?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);
?>

Parse error: syntax error, unexpected T_STRING in /home/a1051468/public_html/FetchUserData.php on line 2

 <?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);

?>
Darwin von Corax
  • 5,201
  • 3
  • 17
  • 28
oliver_13
  • 39
  • 10

1 Answers1

0

The error is not in the line it shows. It must be from the previous php command before this line. In your case, it must be from the very previous line in the file where you included this "FetchUserData.php"

E-g

<?php
 $a = "test

?>


<?php
$con=mysqli_connect('mysql7.000webhost.com','a1051468_oliver','password','a1051468_RegApp');

When i reun this code, the error is in first line. but it show the error as below

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)
Thanga
  • 7,811
  • 3
  • 19
  • 38