So i am trying to create a registersite on my android app. I have been following Toni Kami step by step guide
https://www.youtube.com/watch?v=QxffHgiJ64M&index=1&list=PLe60o7ed8E-TztoF2K3y4VdDgT6APZ0ka
Atm Im at a complete halt and up to hours trying to fix a json exception that im having and i now desperately turn to your fine people for help.
RegisterActivity.java = http://pastebin.com/0zy3UZYc
RegisterRequest.java = http://pastebin.com/RZXfHcmn
register.php = http://pastebin.com/pAuAGnTt
I read around that in most cases it is the URL thats the problem but when i paste the url in chrome then it does echo connected.
this is the return string:
I/tagconvertstr: [
Notice: Undefined variable: con in C:\xampp\htdocs\Yield\PhpFiles\register.php on line 12
Warning: mysqli_prepare() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Yield\PhpFiles\register.php on line 12
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\Yield\PhpFiles\register.php on line 13
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\Yield\PhpFiles\register.php on line 14
the lines it is complaining about are these:
$statement = mysqli_prepare($con, "INSERT INTO users (name, username, age, password) VALUES (?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "siss", $name, $username, $age, $password);
mysqli_stmt_execute($statement);
]
I really hope someone can enlighten me here and feel free to ask for mere information.
Thx!
it is because there is a mix of mysql_ and mysqli_
if you make everything mysqli_
<?php
$con = mysqli_connect("127.0.0.1","root","", "yield");
$name = $_POST["name"];
$age = $_POST["age"];
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "INSERT INTO users (name, username, age, password) VALUES (?, ?, ?, ?)") or die (mysqli_error($con));
mysqli_stmt_bind_param($statement, "siss", $name, $username, $age, $password);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
then it works!