Kettlewell's Recent Forum Activity

  • I was using else statements so that other parts of the code didn't run. If it works like a typical if statement I didn't want it to keep comparing the variables but I removed them anyway.

    I converted the value to an int but unfortunately it still won't run. IsMember returns 1 on a successful login and the debug shows it logs in but the sub events just do not seem to want to fire.

  • I've been using a PHP file made from the Login tutorial and it works fine but I've been trying to force an error by creating an account on the login system with an email that already exists, I'm using this code

    <?php header('Access-Control-Allow-Origin: *');
    
    ini_set('display_errors', 'On');
    error_reporting(E_ALL | E_STRICT);
    
    $email = $_GET['femail'];
    $password = $_GET['fpass'];
    $con=mysqli_connect("mysql2.clusterdb.net","PSDB-9qw","bravo190","PSDB-9qw","3306","/var/lib/mysql/cluster2.sock");
    
    // Check connection
    if (mysqli_connect_errno()){
      echo "-1";
     } else {
    	
    	$qz = "SELECT IsMember FROM UserAuthData where email='".$email."' and password='".$password."'"; 
    	$qz = str_replace("\'","",$qz);
    	$result = mysqli_query($con,$qz);
    
    	if (!$result) {
    		echo "-2";
    	} else {
    		while($row = mysqli_fetch_array($result))
    		{
    			echo $row['IsMember'];
    		}
    	}	 
    }
    
    mysqli_close($con);
    ?>[/code:1q9v6mso]
    
    The problem is with my limited knowledge of php and mysql, I expected this to return a -2 value to ajax like it does when there are no errors due to duplicate unique keys in the database but it doesn't, ajax never returns a value.
    
    Would anyone know why it will return IsMember fine but not -2?
    
    Thank you.
  • Is there any particular reason that the sub events are not firing here?

    I've ensured that the variables are tested and are fine but the sub events will just not fire.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I've learned how to use AJAX, PHP and MySql to return database values but how do you handle multiple values?

    Does AJAX.lastvalue return an array or is there something I have to do to receive multiple values?

    In PHP do I have to do something special or simply;

    echo $var1
    echo $var2[/code:2vyw9z40]
  • AJAX is now operating but the script is returning

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/cluster-sites/2/o/ouroboros-development.co.uk/public_html/login.php on line 17[/code:2n7e4n8h]
  • https:// www scirra com /tutorials/525/simple-login-using-a-mysql-database

    I've been learning as I go along and I've put in plenty of error checks.

    The php script does run and it does connect but the query always returns

    RESULT = END OF RESULT[/code:3s9n1l5m] inside of it but If I run SQL straight in phpmyadmin with the exact same query (Minus the variable = ) then I get a good result of IsMember 1.
    
    I'll look into the AJAX possible issue.
    
    [b]*An AJAX error is occurring as you stated it may[/b]
  • I'm following this login tutorial which uses PHP, AJAX and Mysql (Sorry can't post URLs due to reputation) but my results aren't coming out as I expected and I wondered if someone could assist.

    Login.php located at

    <?php
    $email = $_GET['femail'];
    $password = $_GET['fpass'];
    $con=mysqli_connect("mysql2.clusterdb.net","UserD-1i1","*snipped password*");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    $qz = "SELECT IsMember FROM PlayerLoginData where EmailID='".$email."' and PassID='".$password."'"; 
    $qz = str_replace("\'","",$qz); 
    $result = mysqli_query($con,$qz);
    while($row = mysqli_fetch_array($result))
      {
      echo $row['IsMember'];
      }
    mysqli_close($con);
    ?>[/code:9vz7otb2]
    
    [b]Database details [/b]- Database and database login are the same as default
    [img="http://i.imgur.com/P1fh41q.png"]
    
    [b]Construct 2 Settings[/b] - I was told AJAX returns a string after I attempted to return a [i]tinyint[/i] from the database so I changed it to a [i]string[/i].
    [img="http://i.imgur.com/onLkmxw.png"]
    
    [b]Results[/b] - As an [i]int [/i]I got [b]NaN[/b] in the IsMember after attempting to login but as a string I receive a blank string.
    AJAX last data is also blank.
    
    [b]*With some error checking I have been given this error[/b]
    [code:9vz7otb2]Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/cluster-sites/2/o/ouroboros-development.co.uk/public_html/login.php on line 15[/code:9vz7otb2]
    
    Thank you for any help that any help I receive.
Kettlewell's avatar

Kettlewell

Member since 10 Jun, 2015

None one is following Kettlewell yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies