0

I am building a function and there is an error please help me to resolve this.

The error line is this:-

Parse error:syntax error, unexpected end of file in /home/u854338141/public_html/login/register.php on line 25

My Code:-

<?php
//Recieve username and password from android device or GET request
$user = $_GET['username'];
$pass = $_GET['password'];

//Database connection information
$dbhost = "mysql.hostinger.in";
$dbuser = "u854338141_root";
$dbpass = "1234567";
$dbname = "u854338141_demo";

//Create a connection to databse
$con = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

//Define sql statement for you business logic: registration
$sql = "INSERT into login(username, password) VALUES('" . $user . "', '" . 
$pass . "');

//Execute sql statement
$result = $con->query($sql);

if($result){
echo json_encode(array("Result"=>true));
}else{
echo json_encode(array("Result"=>false));
}
0

3 Answers 3

5

change

//Define sql statement for you business logic: registration
$sql = "INSERT into login(username, password) VALUES('" . $user . "', '" . 
$pass . "')";

add double quote after last bracket

Sign up to request clarification or add additional context in comments.

Comments

2
$sql = "INSERT into login(username, password) VALUES('" . $user . "', '" . 
$pass . "')";

You didn't close the query. There is a missing double quote " at the end of the query just after the closing bracket.

7 Comments

Please don't duplicate answers , be more attentive .....
the only query that he gave. i cannot modified the statement, or the query or the attribute from the original post. The only things that i can do is fixing the missing value, symbol or etc.. It is same when u trying to fixing a words.. Let say someone miss spelled the word airplane, he wrote airplant.. and hes asking whats wrong with the words.. even 10 people answer it, 100% sure they definitely answer AIRPLANE as their answer. And you you come over to those people who answered AIRPLANE and asking them not t duplicate since the only answer is only AIRPLANE..
Dear @parkway It's not about this specific case, it's generally
what else did you can change in the query instead of replacing or adding a missing symbol? since the only problem that clearly
I upvoted your answer , means I agree with your answer , I'm just saying when you see someone already answers don't post same answer that's it , something remains unclear ?
|
0

You code is right just add double qoute in the Insert query and your problem solved. Right code is as follows :

<?php
//Recieve username and password from android device or GET request
$user = $_GET['username'];
$pass = $_GET['password'];

//Database connection information
$dbhost = "mysql.hostinger.in";
$dbuser = "u854338141_root";
$dbpass = "1234567";
$dbname = "u854338141_demo";

//Create a connection to databse
$con = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

//Define sql statement for you business logic: registration
$sql = "INSERT into login(username, password) VALUES('" . $user . "', '" . 
$pass . "')"; // This line you missed double quote ' " ' 

//Execute sql statement
$result = $con->query($sql);

if($result){
echo json_encode(array("Result"=>true));
}else{
echo json_encode(array("Result"=>false));
}

?>

If still you have issue please let us know.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.