I know that this kind of problem has some solutions and applied some solutions for this problem but I can\'t solve and i\'m confused. Please help me. Here is code:
You do not return a valid JSON, seems that you are returning a HTML snippet with <br>
have a look at your returning source of your website.
What should i do? The Php code runs on web page without any errors but why got an error in this part? In logcat also has: ( ! ) Notice: Undefined variable: user_id in C:\wamp\www\getProducts.php on line 27
So the user_id
is not defined! Just look at your GET/POST Parameters or show us your relevant php code.
Please use echo json_encode($output);
not print
.
And what are you doing if there is no returning row from your first Query. Try this.
$sql=mysql_query("SELECT user_id FROM users WHERE user_name='".$user_name."' AND user_pass='".$password."' ");
if(mysql_num_rows($sql) == 0){
echo "USERID CANNOT BE FOUND";
}
while($row=mysql_fetch_array($sql)) {
echo "USERID FOUND" .$row["user_id"] ;
$user_id=$row["user_id"];
}
It seems that user_name
could not be found. So just debug it there by trying to echo your user_id after the while. If you do not get the UserID FOUND echo the user_name and password do not exist.
Edit: As your logact says, there is no Entry for the username you are passing so the $user_id will never be filled.
http://192.168.2.245/getProducts.php?login=1&user_name=UserName&password=Password
You are passing user_name = UserName and password = Password. Does this entry really exist in your Database?
Also for better performance have a look at MySQL LETF JOIN and MySQL subqueries.