I have already looked at various other SO answers and still cannot get this to work. I know that my summonerid
get's through fine as I can echo it back. I also can reach my MySQL table, so it has to be my query syntax.
$query="SELECT FROM UserTable (summonerid) WHERE summonerid='$usersummonerid'";
if(mysql_num_rows($query)<1)
{
//register name
} else {
//name exists already
}
The errors I am getting back
Warning: mysql_query(): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\GVLegends\Scripts\check.php on line 21
Warning: mysql_query(): A link to the server could not be established in C:\xampp\htdocs\GVLegends\Scripts\check.php on line 21
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\GVLegends\Scripts\check.php on line 22
Here is my entire PHP for context (sorry if it seems poorly coded, I am newer to PHP)
<?php
//login details
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$username = $_POST['user'];
$userpassword = $_POST['pass'];
$usersummoner = $_POST['summoner'];
$usersummonerid = $_POST['summonerid'];
$useremail = $_POST['email'];
$query="SELECT FROM UserTable (summonerid) WHERE summonerid='$usersummonerid'";
if(mysql_num_rows($query)<1) {
$sql = "INSERT INTO UserTable (name, password, summonerid, summonername,email)
VALUES ('$username', '$userpassword', '$usersummonerid', '$usersummoner',$useremail')";
if ($conn->query($sql) === TRUE) {
echo '{"success":true}';
} else {
echo '{"success":false}';
}
} else {
echo '{"success":false}';
}
$conn->close();
?>